Merge "Syncronize pdfium initialization between users." into nyc-dev
am: 9594487
* commit '9594487548d42ea13569bd15369382f7283c8d33':
Syncronize pdfium initialization between users.
Change-Id: I39ec811fe0fcd1f3c2ad3af1a36b8ee34762037d
This commit is contained in:
@@ -51,22 +51,22 @@ static struct {
|
||||
jfieldID bottom;
|
||||
} gRectClassInfo;
|
||||
|
||||
static Mutex sLock;
|
||||
|
||||
static int sUnmatchedInitRequestCount = 0;
|
||||
// Also used in PdfRenderer.cpp
|
||||
Mutex sPdfiumLock;
|
||||
int sUnmatchedPdfiumInitRequestCount = 0;
|
||||
|
||||
static void initializeLibraryIfNeeded() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
if (sUnmatchedInitRequestCount == 0) {
|
||||
Mutex::Autolock _l(sPdfiumLock);
|
||||
if (sUnmatchedPdfiumInitRequestCount == 0) {
|
||||
FPDF_InitLibrary();
|
||||
}
|
||||
sUnmatchedInitRequestCount++;
|
||||
sUnmatchedPdfiumInitRequestCount++;
|
||||
}
|
||||
|
||||
static void destroyLibraryIfNeeded() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
sUnmatchedInitRequestCount--;
|
||||
if (sUnmatchedInitRequestCount == 0) {
|
||||
Mutex::Autolock _l(sPdfiumLock);
|
||||
sUnmatchedPdfiumInitRequestCount--;
|
||||
if (sUnmatchedPdfiumInitRequestCount == 0) {
|
||||
FPDF_DestroyLibrary();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,22 +43,22 @@ static struct {
|
||||
jfieldID y;
|
||||
} gPointClassInfo;
|
||||
|
||||
static Mutex sLock;
|
||||
|
||||
static int sUnmatchedInitRequestCount = 0;
|
||||
// See PdfEditor.cpp
|
||||
extern Mutex sPdfiumLock;
|
||||
extern int sUnmatchedPdfiumInitRequestCount;
|
||||
|
||||
static void initializeLibraryIfNeeded() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
if (sUnmatchedInitRequestCount == 0) {
|
||||
Mutex::Autolock _l(sPdfiumLock);
|
||||
if (sUnmatchedPdfiumInitRequestCount == 0) {
|
||||
FPDF_InitLibrary();
|
||||
}
|
||||
sUnmatchedInitRequestCount++;
|
||||
sUnmatchedPdfiumInitRequestCount++;
|
||||
}
|
||||
|
||||
static void destroyLibraryIfNeeded() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
sUnmatchedInitRequestCount--;
|
||||
if (sUnmatchedInitRequestCount == 0) {
|
||||
Mutex::Autolock _l(sPdfiumLock);
|
||||
sUnmatchedPdfiumInitRequestCount--;
|
||||
if (sUnmatchedPdfiumInitRequestCount == 0) {
|
||||
FPDF_DestroyLibrary();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user