static install_status_t iterateOverNativeFiles(JNIEnv *env, jstring javaFilePath, jstring javaCpuAbi, jstring javaCpuAbi2, iterFunc callFunc, void* callArg) { ScopedUtfChars filePath(env, javaFilePath); ScopedUtfChars cpuAbi(env, javaCpuAbi); ScopedUtfChars cpuAbi2(env, javaCpuAbi2); ZipFileRO zipFile; if (zipFile.open(filePath.c_str()) != NO_ERROR) { ALOGI("Couldn't open APK %s\n", filePath.c_str()); return INSTALL_FAILED_INVALID_APK; } const int N = zipFile.getNumEntries(); char fileName[PATH_MAX]; bool hasPrimaryAbi = false; for (int i = 0; i < N; i++) { const ZipEntryRO entry = zipFile.findEntryByIndex(i); if (entry == NULL) { continue; } // Make sure this entry has a filename. if (zipFile.getEntryFileName(entry, fileName, sizeof(fileName))) { continue; } // Make sure we're in the lib directory of the ZIP. if (strncmp(fileName, APK_LIB, APK_LIB_LEN)) { continue; } // Make sure the filename is at least to the minimum library name size. const size_t fileNameLen = strlen(fileName); static const size_t minLength = APK_LIB_LEN + 2 + LIB_PREFIX_LEN + 1 + LIB_SUFFIX_LEN; if (fileNameLen < minLength) { continue; } const char* lastSlash = strrchr(fileName, '/'); ALOG_ASSERT(lastSlash != NULL, "last slash was null somehow for %s\n", fileName); // Check to make sure the CPU ABI of this file is one we support. const char* cpuAbiOffset = fileName + APK_LIB_LEN; const size_t cpuAbiRegionSize = lastSlash - cpuAbiOffset; ALOGV("Comparing ABIs %s and %s versus %s\n", cpuAbi.c_str(), cpuAbi2.c_str(), cpuAbiOffset); if (cpuAbi.size() == cpuAbiRegionSize && *(cpuAbiOffset + cpuAbi.size()) == '/' && !strncmp(cpuAbiOffset, cpuAbi.c_str(), cpuAbiRegionSize)) { ALOGV("Using primary ABI %s\n", cpuAbi.c_str()); hasPrimaryAbi = true; } else if (cpuAbi2.size() == cpuAbiRegionSize && *(cpuAbiOffset + cpuAbi2.size()) == '/' && !strncmp(cpuAbiOffset, cpuAbi2.c_str(), cpuAbiRegionSize)) { /* * If this library matches both the primary and secondary ABIs, * only use the primary ABI. */ if (hasPrimaryAbi) { ALOGV("Already saw primary ABI, skipping secondary ABI %s\n", cpuAbi2.c_str()); continue; } else { ALOGV("Using secondary ABI %s\n", cpuAbi2.c_str()); } } else { ALOGV("abi didn't match anything: %s (end at %zd)\n", cpuAbiOffset, cpuAbiRegionSize); continue; } // If this is a .so file, check to see if we need to copy it. if ((!strncmp(fileName + fileNameLen - LIB_SUFFIX_LEN, LIB_SUFFIX, LIB_SUFFIX_LEN) && !strncmp(lastSlash, LIB_PREFIX, LIB_PREFIX_LEN) && isFilenameSafe(lastSlash + 1)) || !strncmp(lastSlash + 1, GDBSERVER, GDBSERVER_LEN)) { install_status_t ret = callFunc(env, callArg, &zipFile, entry, lastSlash + 1); if (ret != INSTALL_SUCCEEDED) { ALOGV("Failure for entry %s", lastSlash + 1); return ret; } } } return INSTALL_SUCCEEDED; }
status_t Camera3OutputStream::configureQueueLocked() { status_t res; mTraceFirstBuffer = true; if ((res = Camera3IOStreamBase::configureQueueLocked()) != OK) { return res; } ALOG_ASSERT(mConsumer != 0, "mConsumer should never be NULL"); // Configure consumer-side ANativeWindow interface res = native_window_api_connect(mConsumer.get(), NATIVE_WINDOW_API_CAMERA); if (res != OK) { ALOGE("%s: Unable to connect to native window for stream %d", __FUNCTION__, mId); return res; } res = native_window_set_usage(mConsumer.get(), camera3_stream::usage); if (res != OK) { ALOGE("%s: Unable to configure usage %08x for stream %d", __FUNCTION__, camera3_stream::usage, mId); return res; } res = native_window_set_scaling_mode(mConsumer.get(), NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW); if (res != OK) { ALOGE("%s: Unable to configure stream scaling: %s (%d)", __FUNCTION__, strerror(-res), res); return res; } if (mMaxSize == 0) { // For buffers of known size res = native_window_set_buffers_dimensions(mConsumer.get(), camera3_stream::width, camera3_stream::height); } else { // For buffers with bounded size res = native_window_set_buffers_dimensions(mConsumer.get(), mMaxSize, 1); } if (res != OK) { ALOGE("%s: Unable to configure stream buffer dimensions" " %d x %d (maxSize %zu) for stream %d", __FUNCTION__, camera3_stream::width, camera3_stream::height, mMaxSize, mId); return res; } res = native_window_set_buffers_format(mConsumer.get(), camera3_stream::format); if (res != OK) { ALOGE("%s: Unable to configure stream buffer format %#x for stream %d", __FUNCTION__, camera3_stream::format, mId); return res; } int maxConsumerBuffers; res = mConsumer->query(mConsumer.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &maxConsumerBuffers); if (res != OK) { ALOGE("%s: Unable to query consumer undequeued" " buffer count for stream %d", __FUNCTION__, mId); return res; } ALOGV("%s: Consumer wants %d buffers, HAL wants %d", __FUNCTION__, maxConsumerBuffers, camera3_stream::max_buffers); if (camera3_stream::max_buffers == 0) { ALOGE("%s: Camera HAL requested max_buffer count: %d, requires at least 1", __FUNCTION__, camera3_stream::max_buffers); return INVALID_OPERATION; } mTotalBufferCount = maxConsumerBuffers + camera3_stream::max_buffers; mHandoutTotalBufferCount = 0; mFrameCount = 0; mLastTimestamp = 0; res = native_window_set_buffer_count(mConsumer.get(), mTotalBufferCount); if (res != OK) { ALOGE("%s: Unable to set buffer count for stream %d", __FUNCTION__, mId); return res; } res = native_window_set_buffers_transform(mConsumer.get(), mTransform); if (res != OK) { ALOGE("%s: Unable to configure stream transform to %x: %s (%d)", __FUNCTION__, mTransform, strerror(-res), res); } return OK; }
static void Sync(JNIEnv* env, jobject obj, jint frame) { WebCore::Frame* pFrame = (WebCore::Frame*)frame; ALOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__); WebCore::Settings* s = pFrame->settings(); if (!s) return; WebCore::CachedResourceLoader* cachedResourceLoader = pFrame->document()->cachedResourceLoader(); #ifdef ANDROID_LAYOUT jobject layout = env->GetObjectField(obj, gFieldIds->mLayoutAlgorithm); WebCore::Settings::LayoutAlgorithm l = (WebCore::Settings::LayoutAlgorithm) env->CallIntMethod(layout, gFieldIds->mOrdinal); if (s->layoutAlgorithm() != l) { s->setLayoutAlgorithm(l); if (pFrame->document()) { pFrame->document()->styleSelectorChanged(WebCore::RecalcStyleImmediately); if (pFrame->document()->renderer()) { recursiveCleanupForFullLayout(pFrame->document()->renderer()); ALOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout"); pFrame->view()->layout(); // FIXME: This call used to scroll the page to put the focus into view. // It worked on the WebViewCore, but now scrolling is done outside of the // WebViewCore, on the UI side, so there needs to be a new way to do this. //pFrame->makeFocusVisible(); } } } #endif jint textSize = env->GetIntField(obj, gFieldIds->mTextSize); float zoomFactor = textSize / 100.0f; if (pFrame->textZoomFactor() != zoomFactor) pFrame->setTextZoomFactor(zoomFactor); jstring str = (jstring)env->GetObjectField(obj, gFieldIds->mStandardFontFamily); s->setStandardFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mFixedFontFamily); s->setFixedFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mSansSerifFontFamily); s->setSansSerifFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mSerifFontFamily); s->setSerifFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mCursiveFontFamily); s->setCursiveFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mFantasyFontFamily); s->setFantasyFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mDefaultTextEncoding); //SAMSUNG Change >> String defaultEncoding = jstringToWtfString(env, str); if (defaultEncoding == "AutoDetect") { s->setUsesEncodingDetector(true); } else { s->setUsesEncodingDetector(false); s->setDefaultTextEncodingName(defaultEncoding); } //SAMSUNG Change << //s->setDefaultTextEncodingName(jstringToWtfString(env, str)); str = (jstring)env->CallObjectMethod(obj, gFieldIds->mGetUserAgentString);//4.2 Merge WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str)); WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent(); jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode); WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextCacheMode(cacheMode); str = (jstring)env->CallObjectMethod(obj, gFieldIds->mGetAcceptLanguage);//4.2 Merge WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str)); jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize); s->setMinimumFontSize(size); size = env->GetIntField(obj, gFieldIds->mMinimumLogicalFontSize); s->setMinimumLogicalFontSize(size); size = env->GetIntField(obj, gFieldIds->mDefaultFontSize); s->setDefaultFontSize(size); size = env->GetIntField(obj, gFieldIds->mDefaultFixedFontSize); s->setDefaultFixedFontSize(size); jboolean flag = env->GetBooleanField(obj, gFieldIds->mLoadsImagesAutomatically); s->setLoadsImagesAutomatically(flag); if (flag) cachedResourceLoader->setAutoLoadImages(true); #ifdef ANDROID_BLOCK_NETWORK_IMAGE flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkImage); s->setBlockNetworkImage(flag); if(!flag) cachedResourceLoader->setBlockNetworkImage(false); #endif flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkLoads); WebFrame* webFrame = WebFrame::getWebFrame(pFrame); webFrame->setBlockNetworkLoads(flag); flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled); s->setJavaScriptEnabled(flag); // SERI - WebGL >> #if ENABLE(WEBGL) flag = env->GetBooleanField(obj, gFieldIds->mWebGLEnabled); s->setWebGLEnabled(flag); #endif // SERI - WebGL << flag = env->GetBooleanField(obj, gFieldIds->mAllowUniversalAccessFromFileURLs); s->setAllowUniversalAccessFromFileURLs(flag); flag = env->GetBooleanField(obj, gFieldIds->mAllowFileAccessFromFileURLs); s->setAllowFileAccessFromFileURLs(flag); // Hyperlink auditing (the ping attribute) has similar privacy // considerations as does the running of JavaScript, so to keep the UI // simpler, we leverage the same setting. s->setHyperlinkAuditingEnabled(flag); // ON = 0 // ON_DEMAND = 1 // OFF = 2 jobject pluginState = env->GetObjectField(obj, gFieldIds->mPluginState); int state = env->CallIntMethod(pluginState, gFieldIds->mOrdinal); s->setPluginsEnabled(state < 2); #ifdef ANDROID_PLUGINS s->setPluginsOnDemand(state == 1); #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) // We only enable AppCache if it's been enabled with a call to // setAppCacheEnabled() and if a valid path has been supplied to // setAppCachePath(). Note that the path is applied to all WebViews // whereas enabling is applied per WebView. // WebCore asserts that the path is only set once. Since the path is // shared between WebViews, we can't do the required checks to guard // against this in the Java WebSettings. bool isPathValid = false; if (cacheStorage().cacheDirectory().isNull()) { str = static_cast<jstring>(env->GetObjectField(obj, gFieldIds->mAppCachePath)); // Check for non-null string as an optimization, as this is the common case. if (str) { String path = jstringToWtfString(env, str); ALOG_ASSERT(!path.empty(), "Java side should never send empty string for AppCache path"); // This database is created on the first load. If the file // doesn't exist, we create it and set its permissions. The // filename must match that in ApplicationCacheStorage.cpp. String filename = pathByAppendingComponent(path, "ApplicationCache.db"); int fd = open(filename.utf8().data(), O_CREAT, permissionFlags660); if (fd >= 0) { close(fd); cacheStorage().setCacheDirectory(path); isPathValid = true; } } } else isPathValid = true; flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled); s->setOfflineWebApplicationCacheEnabled(flag && isPathValid); jlong maxsize = env->GetLongField(obj, gFieldIds->mAppCacheMaxSize); cacheStorage().setMaximumSize(maxsize); #endif flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptCanOpenWindowsAutomatically); s->setJavaScriptCanOpenWindowsAutomatically(flag); #ifdef ANDROID_LAYOUT flag = env->GetBooleanField(obj, gFieldIds->mUseWideViewport); s->setUseWideViewport(flag); #endif #ifdef ANDROID_MULTIPLE_WINDOWS flag = env->GetBooleanField(obj, gFieldIds->mSupportMultipleWindows); s->setSupportMultipleWindows(flag); #endif flag = env->GetBooleanField(obj, gFieldIds->mShrinksStandaloneImagesToFit); s->setShrinksStandaloneImagesToFit(flag); jlong maxImage = env->GetLongField(obj, gFieldIds->mMaximumDecodedImageSize); // Since in ImageSourceAndroid.cpp, the image will always not exceed // MAX_SIZE_BEFORE_SUBSAMPLE, there's no need to pass the max value to // WebCore, which checks (image_width * image_height * 4) as an // estimation against the max value, which is done in CachedImage.cpp. // And there're cases where the decoded image size will not // exceed the max, but the WebCore estimation will. So the following // code is commented out to fix those cases. // if (maxImage == 0) // maxImage = computeMaxBitmapSizeForCache(); s->setMaximumDecodedImageSize(maxImage); flag = env->GetBooleanField(obj, gFieldIds->mPrivateBrowsingEnabled); s->setPrivateBrowsingEnabled(flag); flag = env->GetBooleanField(obj, gFieldIds->mSyntheticLinksEnabled); s->setDefaultFormatDetection(flag); s->setFormatDetectionAddress(flag); s->setFormatDetectionEmail(flag); s->setFormatDetectionTelephone(flag); #if ENABLE(DATABASE) flag = env->GetBooleanField(obj, gFieldIds->mDatabaseEnabled); WebCore::Database::setIsAvailable(flag); flag = env->GetBooleanField(obj, gFieldIds->mDatabasePathHasBeenSet); if (flag) { // If the user has set the database path, sync it to the DatabaseTracker. str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); if (str) { String path = jstringToWtfString(env, str); DatabaseTracker::tracker().setDatabaseDirectoryPath(path); // This database is created when the first HTML5 Database object is // instantiated. If the file doesn't exist, we create it and set its // permissions. The filename must match that in // DatabaseTracker.cpp. String filename = SQLiteFileSystem::appendDatabaseFileNameToPath(path, "Databases.db"); int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); if (fd >= 0) close(fd); } } #endif #if ENABLE(FILE_SYSTEM) flag = env->GetBooleanField(obj, gFieldIds->mFilesystemEnabled); flag = env->GetBooleanField(obj, gFieldIds->mFileSystemPathHasBeenSet); if (flag) { // If the user has set the filesystem path, sync it to the LocalFileSystem. str = (jstring)env->GetObjectField(obj, gFieldIds->mFileSystemPath); if (str) { String path = jstringToWtfString(env, str); LocalFileSystem::localFileSystem().initializeLocalFileSystem(path); } } #endif // Samsung Change - HTML5 Web Notification >> #if ENABLE(NOTIFICATIONS) flag = env->GetBooleanField(obj, gFieldIds->mWebnotificationEnabled); //flag = env->GetBooleanField(obj, gFieldIds->mFileSystemPathHasBeenSet); //if (flag) { // If the user has set the Web notification path, sync it to the NotificationPresenterImpl. str = (jstring)env->GetObjectField(obj, gFieldIds->mWebnotificationDatabasePath); if (str) { String path = jstringToWtfString(env, str); NotificationPresenterImpl::setDatabasePath(path); } // ALWAYS ON = 0 // ON_DEMAND = 1 // OFF = 2 jobject notificationState = env->GetObjectField(obj, gFieldIds->mNotificationState); int notifystate = env->CallIntMethod(notificationState, gFieldIds->mOrdinal); NotificationPresenterImpl::setSettingsValue(notifystate); //s->setPluginsEnabled(state < 2); //} #endif // Samsung Change - HTML5 Web Notification << #if ENABLE(DOM_STORAGE) flag = env->GetBooleanField(obj, gFieldIds->mDomStorageEnabled); s->setLocalStorageEnabled(flag); str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); if (str) { WTF::String localStorageDatabasePath = jstringToWtfString(env,str); if (localStorageDatabasePath.length()) { localStorageDatabasePath = WebCore::pathByAppendingComponent( localStorageDatabasePath, "localstorage"); // We need 770 for folders mkdir(localStorageDatabasePath.utf8().data(), permissionFlags660 | S_IXUSR | S_IXGRP); s->setLocalStorageDatabasePath(localStorageDatabasePath); } } #endif //SISO_HTMLComposer Start flag = env->GetBooleanField(obj, gFieldIds->mEditableSupport); if(flag) s->setEditableLinkBehavior(WebCore::EditableLinkNeverLive); s->setEditableSupportEnabled(flag); flag = env->GetBooleanField(obj, gFieldIds->mDisableAnimation); s->setDisableAnimation(flag); flag = env->GetBooleanField(obj, gFieldIds->mHighResolutionDevice); s->setHighResolutionDevice(flag); //SISO_HTMLComposer End //SAMSUNG ADVANCED TEXT SELECTION - BEGIN flag = env->GetBooleanField(obj, gFieldIds->mAdvanceTextSelection); s->setAdvancedSelectionEnabled(flag); jlong color = env->GetLongField(obj, gFieldIds->mAdvanceSelectionBgColor); if (-1 != color) { int r = ((color & 0x00FF0000) >> 16); int g = ((color & 0x0000FF00) >> 8); int b = (color & 0x000000FF); s->setAdvancedSelectionBgColor(r, g, b); }
static void unitTest() { ALOGD("Entering history unit test!"); const char* test1 = new char[0]; WTF::RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(); WebCore::HistoryItem* testItem = item.get(); testItem->setBridge(new WebHistoryItem(0)); ALOG_ASSERT(!readItemRecursive(testItem, &test1, 0), "0 length array should fail!"); delete[] test1; const char* test2 = new char[2]; ALOG_ASSERT(!readItemRecursive(testItem, &test2, 2), "Small array should fail!"); delete[] test2; ALOG_ASSERT(!readItemRecursive(testItem, NULL, HISTORY_MIN_SIZE), "Null data should fail!"); // Original Url char* test3 = new char[HISTORY_MIN_SIZE]; const char* ptr = (const char*)test3; memset(test3, 0, HISTORY_MIN_SIZE); *(int*)test3 = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length originalUrl should fail!"); // Url int offset = 4; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length url should fail!"); // Title offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length title should fail!"); // Form content type offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length contentType should fail!"); // Form data offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length form data should fail!"); // Target offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length target should fail!"); offset += 4; // Screen scale offset += 4; // Text wrap scale offset += 4; // Scroll pos x offset += 4; // Scroll pos y // Document state offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 length document state should fail!"); // Is target item offset += 1; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(char*)(test3 + offset) = '!'; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "IsTargetItem should fail with ! as the value!"); // Child count offset += 4; memset(test3, 0, HISTORY_MIN_SIZE); ptr = (const char*)test3; *(int*)(test3 + offset) = 4000; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE), "4000 kids should fail!"); // Test document state offset = 40; delete[] test3; test3 = new char[HISTORY_MIN_SIZE + sizeof(unsigned)]; memset(test3, 0, HISTORY_MIN_SIZE + sizeof(unsigned)); ptr = (const char*)test3; *(int*)(test3 + offset) = 1; *(int*)(test3 + offset + 4) = 20; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE + sizeof(unsigned)), "1 20 length document state string should fail!"); delete[] test3; test3 = new char[HISTORY_MIN_SIZE + 2 * sizeof(unsigned)]; memset(test3, 0, HISTORY_MIN_SIZE + 2 * sizeof(unsigned)); ptr = (const char*)test3; *(int*)(test3 + offset) = 2; *(int*)(test3 + offset + 4) = 0; *(int*)(test3 + offset + 8) = 20; ALOG_ASSERT(!readItemRecursive(testItem, &ptr, HISTORY_MIN_SIZE + 2 * sizeof(unsigned) ), "2 20 length document state string should fail!"); delete[] test3; ALOGD("Leaving history unit test!"); }
status_t Camera3OutputStream::returnBufferCheckedLocked( const camera3_stream_buffer &buffer, nsecs_t timestamp, bool output, /*out*/ sp<Fence> *releaseFenceOut) { (void)output; ALOG_ASSERT(output, "Expected output to be true"); status_t res; sp<Fence> releaseFence; /** * Fence management - calculate Release Fence */ if (buffer.status == CAMERA3_BUFFER_STATUS_ERROR) { if (buffer.release_fence != -1) { ALOGE("%s: Stream %d: HAL should not set release_fence(%d) when " "there is an error", __FUNCTION__, mId, buffer.release_fence); close(buffer.release_fence); } /** * Reassign release fence as the acquire fence in case of error */ releaseFence = new Fence(buffer.acquire_fence); } else { res = native_window_set_buffers_timestamp(mConsumer.get(), timestamp); if (res != OK) { ALOGE("%s: Stream %d: Error setting timestamp: %s (%d)", __FUNCTION__, mId, strerror(-res), res); return res; } releaseFence = new Fence(buffer.release_fence); } int anwReleaseFence = releaseFence->dup(); /** * Release the lock briefly to avoid deadlock with * StreamingProcessor::startStream -> Camera3Stream::isConfiguring (this * thread will go into StreamingProcessor::onFrameAvailable) during * queueBuffer */ sp<ANativeWindow> currentConsumer = mConsumer; mLock.unlock(); /** * Return buffer back to ANativeWindow */ if (buffer.status == CAMERA3_BUFFER_STATUS_ERROR) { // Cancel buffer res = currentConsumer->cancelBuffer(currentConsumer.get(), container_of(buffer.buffer, ANativeWindowBuffer, handle), anwReleaseFence); if (res != OK) { ALOGE("%s: Stream %d: Error cancelling buffer to native window:" " %s (%d)", __FUNCTION__, mId, strerror(-res), res); } } else { if (mTraceFirstBuffer && (stream_type == CAMERA3_STREAM_OUTPUT)) { { char traceLog[48]; snprintf(traceLog, sizeof(traceLog), "Stream %d: first full buffer\n", mId); ATRACE_NAME(traceLog); } mTraceFirstBuffer = false; } res = currentConsumer->queueBuffer(currentConsumer.get(), container_of(buffer.buffer, ANativeWindowBuffer, handle), anwReleaseFence); if (res != OK) { ALOGE("%s: Stream %d: Error queueing buffer to native window: " "%s (%d)", __FUNCTION__, mId, strerror(-res), res); } } mLock.lock(); if (res != OK) { close(anwReleaseFence); } *releaseFenceOut = releaseFence; return res; }
void SurfaceMediaSource::onSidebandStreamChanged() { ALOG_ASSERT(false, "SurfaceMediaSource can't consume sideband streams"); }
status_t TimestretchBufferProvider::getNextBuffer( AudioBufferProvider::Buffer *pBuffer, int64_t pts) { ALOGV("TimestretchBufferProvider(%p)::getNextBuffer(%p (%zu), %lld)", this, pBuffer, pBuffer->frameCount, pts); // BYPASS //return mTrackBufferProvider->getNextBuffer(pBuffer, pts); // check if previously processed data is sufficient. if (pBuffer->frameCount <= mRemaining) { ALOGV("previous sufficient"); pBuffer->raw = mLocalBufferData; return OK; } // do we need to resize our buffer? if (pBuffer->frameCount > mLocalBufferFrameCount) { void *newmem; if (posix_memalign(&newmem, 32, pBuffer->frameCount * mFrameSize) == OK) { if (mRemaining != 0) { memcpy(newmem, mLocalBufferData, mRemaining * mFrameSize); } free(mLocalBufferData); mLocalBufferData = newmem; mLocalBufferFrameCount = pBuffer->frameCount; } } // need to fetch more data const size_t outputDesired = pBuffer->frameCount - mRemaining; size_t dstAvailable; do { mBuffer.frameCount = mPlaybackRate.mSpeed == AUDIO_TIMESTRETCH_SPEED_NORMAL ? outputDesired : outputDesired * mPlaybackRate.mSpeed + 1; status_t res = mTrackBufferProvider->getNextBuffer(&mBuffer, pts); ALOG_ASSERT(res == OK || mBuffer.frameCount == 0); if (res != OK || mBuffer.frameCount == 0) { // not needed by API spec, but to be safe. ALOGV("upstream provider cannot provide data"); if (mRemaining == 0) { pBuffer->raw = NULL; pBuffer->frameCount = 0; return res; } else { // return partial count pBuffer->raw = mLocalBufferData; pBuffer->frameCount = mRemaining; return OK; } } // time-stretch the data dstAvailable = min(mLocalBufferFrameCount - mRemaining, outputDesired); size_t srcAvailable = mBuffer.frameCount; processFrames((uint8_t*)mLocalBufferData + mRemaining * mFrameSize, &dstAvailable, mBuffer.raw, &srcAvailable); // release all data consumed mBuffer.frameCount = srcAvailable; mTrackBufferProvider->releaseBuffer(&mBuffer); } while (dstAvailable == 0); // try until we get output data or upstream provider fails. // update buffer vars with the actual data processed and return with buffer mRemaining += dstAvailable; pBuffer->raw = mLocalBufferData; pBuffer->frameCount = mRemaining; return OK; }
static void historyItemChanged(WebCore::HistoryItem* item) { ALOG_ASSERT(item, "historyItemChanged called with a null item"); if (item->bridge()) item->bridge()->updateHistoryItem(item); }
static void writeItem(WTF::Vector<char>& vector, WebCore::HistoryItem* item) { // Original url writeString(vector, item->originalURLString()); // Url writeString(vector, item->urlString()); // Title writeString(vector, item->title()); // Form content type writeString(vector, item->formContentType()); // Form data const WebCore::FormData* formData = item->formData(); if (formData) { // write a flag means formData is not null. unsigned flag = FLAG_NOT_NULL; vector.append((char*)&flag, sizeof(unsigned)); //LOGD("Writing Form data if {} Tag"); /*guoxiaolei 20120827 end>*/ writeString(vector, formData->flattenToString()); // save the identifier as it is not included in the flatten data int64_t id = formData->identifier(); //LOGD("Writing the identifier %d ", id); /*guoxiaolei 20120827 end>*/ vector.append((char*)&id, sizeof(int64_t)); } else{ //LOGD("Writing Form data else {} Tag"); //write_string(v, WTF::String()); // Empty constructor does not allocate a buffer. // write a flag means formData is null. unsigned flag = FLAG_IS_NULL; vector.append((char*)&flag, sizeof(unsigned)); } /*guoxiaolei 20120827 end>*/ // Target writeString(vector, item->target()); AndroidWebHistoryBridge* bridge = item->bridge(); ALOG_ASSERT(bridge, "We should have a bridge here!"); // Screen scale const float scale = bridge->scale(); ALOGV("Writing scale %f", scale); vector.append((char*)&scale, sizeof(float)); const float textWrapScale = bridge->textWrapScale(); ALOGV("Writing text wrap scale %f", textWrapScale); vector.append((char*)&textWrapScale, sizeof(float)); // Scroll position. const int scrollX = item->scrollPoint().x(); vector.append((char*)&scrollX, sizeof(int)); const int scrollY = item->scrollPoint().y(); vector.append((char*)&scrollY, sizeof(int)); // Document state const WTF::Vector<WTF::String>& docState = item->documentState(); WTF::Vector<WTF::String>::const_iterator end = docState.end(); unsigned stateSize = docState.size(); ALOGV("Writing docState %d", stateSize); vector.append((char*)&stateSize, sizeof(unsigned)); for (WTF::Vector<WTF::String>::const_iterator i = docState.begin(); i != end; ++i) { writeString(vector, *i); } // Is target item ALOGV("Writing isTargetItem %d", item->isTargetItem()); vector.append((char)item->isTargetItem()); // Children count unsigned childCount = item->children().size(); ALOGV("Writing childCount %d", childCount); vector.append((char*)&childCount, sizeof(unsigned)); }
FieldIds(JNIEnv* env, jclass clazz) { mLayoutAlgorithm = env->GetFieldID(clazz, "mLayoutAlgorithm", "Landroid/webkit/WebSettings$LayoutAlgorithm;"); mTextSize = env->GetFieldID(clazz, "mTextSize", "I"); mStandardFontFamily = env->GetFieldID(clazz, "mStandardFontFamily", "Ljava/lang/String;"); mFixedFontFamily = env->GetFieldID(clazz, "mFixedFontFamily", "Ljava/lang/String;"); mSansSerifFontFamily = env->GetFieldID(clazz, "mSansSerifFontFamily", "Ljava/lang/String;"); mSerifFontFamily = env->GetFieldID(clazz, "mSerifFontFamily", "Ljava/lang/String;"); mCursiveFontFamily = env->GetFieldID(clazz, "mCursiveFontFamily", "Ljava/lang/String;"); mFantasyFontFamily = env->GetFieldID(clazz, "mFantasyFontFamily", "Ljava/lang/String;"); mDefaultTextEncoding = env->GetFieldID(clazz, "mDefaultTextEncoding", "Ljava/lang/String;"); mUserAgent = env->GetFieldID(clazz, "mUserAgent", "Ljava/lang/String;"); mAcceptLanguage = env->GetFieldID(clazz, "mAcceptLanguage", "Ljava/lang/String;"); mMinimumFontSize = env->GetFieldID(clazz, "mMinimumFontSize", "I"); mMinimumLogicalFontSize = env->GetFieldID(clazz, "mMinimumLogicalFontSize", "I"); mDefaultFontSize = env->GetFieldID(clazz, "mDefaultFontSize", "I"); mDefaultFixedFontSize = env->GetFieldID(clazz, "mDefaultFixedFontSize", "I"); mLoadsImagesAutomatically = env->GetFieldID(clazz, "mLoadsImagesAutomatically", "Z"); mMediaPreloadEnabled = env->GetFieldID(clazz, "mMediaPreloadEnabled", "Z"); #ifdef ANDROID_BLOCK_NETWORK_IMAGE mBlockNetworkImage = env->GetFieldID(clazz, "mBlockNetworkImage", "Z"); #endif mBlockNetworkLoads = env->GetFieldID(clazz, "mBlockNetworkLoads", "Z"); mJavaScriptEnabled = env->GetFieldID(clazz, "mJavaScriptEnabled", "Z"); mAllowUniversalAccessFromFileURLs = env->GetFieldID(clazz, "mAllowUniversalAccessFromFileURLs", "Z"); mAllowFileAccessFromFileURLs = env->GetFieldID(clazz, "mAllowFileAccessFromFileURLs", "Z"); mPluginState = env->GetFieldID(clazz, "mPluginState", "Landroid/webkit/WebSettings$PluginState;"); #if ENABLE(DATABASE) mDatabaseEnabled = env->GetFieldID(clazz, "mDatabaseEnabled", "Z"); #endif #if ENABLE(DOM_STORAGE) mDomStorageEnabled = env->GetFieldID(clazz, "mDomStorageEnabled", "Z"); #endif #if ENABLE(DATABASE) || ENABLE(DOM_STORAGE) // The databases saved to disk for both the SQL and DOM Storage APIs are stored // in the same base directory. mDatabasePath = env->GetFieldID(clazz, "mDatabasePath", "Ljava/lang/String;"); mDatabasePathHasBeenSet = env->GetFieldID(clazz, "mDatabasePathHasBeenSet", "Z"); #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) mAppCacheEnabled = env->GetFieldID(clazz, "mAppCacheEnabled", "Z"); mAppCachePath = env->GetFieldID(clazz, "mAppCachePath", "Ljava/lang/String;"); mAppCacheMaxSize = env->GetFieldID(clazz, "mAppCacheMaxSize", "J"); #endif #if ENABLE(WORKERS) mWorkersEnabled = env->GetFieldID(clazz, "mWorkersEnabled", "Z"); #endif mGeolocationEnabled = env->GetFieldID(clazz, "mGeolocationEnabled", "Z"); mGeolocationDatabasePath = env->GetFieldID(clazz, "mGeolocationDatabasePath", "Ljava/lang/String;"); mXSSAuditorEnabled = env->GetFieldID(clazz, "mXSSAuditorEnabled", "Z"); #if ENABLE(LINK_PREFETCH) mLinkPrefetchEnabled = env->GetFieldID(clazz, "mLinkPrefetchEnabled", "Z"); #endif mJavaScriptCanOpenWindowsAutomatically = env->GetFieldID(clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z"); mUseWideViewport = env->GetFieldID(clazz, "mUseWideViewport", "Z"); mSupportMultipleWindows = env->GetFieldID(clazz, "mSupportMultipleWindows", "Z"); mShrinksStandaloneImagesToFit = env->GetFieldID(clazz, "mShrinksStandaloneImagesToFit", "Z"); mMaximumDecodedImageSize = env->GetFieldID(clazz, "mMaximumDecodedImageSize", "J"); mPrivateBrowsingEnabled = env->GetFieldID(clazz, "mPrivateBrowsingEnabled", "Z"); mSyntheticLinksEnabled = env->GetFieldID(clazz, "mSyntheticLinksEnabled", "Z"); mUseDoubleTree = env->GetFieldID(clazz, "mUseDoubleTree", "Z"); mPageCacheCapacity = env->GetFieldID(clazz, "mPageCacheCapacity", "I"); #if ENABLE(WEB_AUTOFILL) mAutoFillEnabled = env->GetFieldID(clazz, "mAutoFillEnabled", "Z"); mAutoFillProfile = env->GetFieldID(clazz, "mAutoFillProfile", "Landroid/webkit/WebSettingsClassic$AutoFillProfile;"); jclass autoFillProfileClass = env->FindClass("android/webkit/WebSettingsClassic$AutoFillProfile"); mAutoFillProfileFullName = env->GetFieldID(autoFillProfileClass, "mFullName", "Ljava/lang/String;"); mAutoFillProfileEmailAddress = env->GetFieldID(autoFillProfileClass, "mEmailAddress", "Ljava/lang/String;"); mAutoFillProfileCompanyName = env->GetFieldID(autoFillProfileClass, "mCompanyName", "Ljava/lang/String;"); mAutoFillProfileAddressLine1 = env->GetFieldID(autoFillProfileClass, "mAddressLine1", "Ljava/lang/String;"); mAutoFillProfileAddressLine2 = env->GetFieldID(autoFillProfileClass, "mAddressLine2", "Ljava/lang/String;"); mAutoFillProfileCity = env->GetFieldID(autoFillProfileClass, "mCity", "Ljava/lang/String;"); mAutoFillProfileState = env->GetFieldID(autoFillProfileClass, "mState", "Ljava/lang/String;"); mAutoFillProfileZipCode = env->GetFieldID(autoFillProfileClass, "mZipCode", "Ljava/lang/String;"); mAutoFillProfileCountry = env->GetFieldID(autoFillProfileClass, "mCountry", "Ljava/lang/String;"); mAutoFillProfilePhoneNumber = env->GetFieldID(autoFillProfileClass, "mPhoneNumber", "Ljava/lang/String;"); env->DeleteLocalRef(autoFillProfileClass); #endif mUserAgentProfile = env->GetFieldID(clazz, "mUserAgentProfile", "Ljava/lang/String;"); mOverrideCacheMode = env->GetFieldID(clazz, "mOverrideCacheMode", "I"); mPasswordEchoEnabled = env->GetFieldID(clazz, "mPasswordEchoEnabled", "Z"); ALOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); ALOG_ASSERT(mTextSize, "Could not find field mTextSize"); ALOG_ASSERT(mStandardFontFamily, "Could not find field mStandardFontFamily"); ALOG_ASSERT(mFixedFontFamily, "Could not find field mFixedFontFamily"); ALOG_ASSERT(mSansSerifFontFamily, "Could not find field mSansSerifFontFamily"); ALOG_ASSERT(mSerifFontFamily, "Could not find field mSerifFontFamily"); ALOG_ASSERT(mCursiveFontFamily, "Could not find field mCursiveFontFamily"); ALOG_ASSERT(mFantasyFontFamily, "Could not find field mFantasyFontFamily"); ALOG_ASSERT(mDefaultTextEncoding, "Could not find field mDefaultTextEncoding"); ALOG_ASSERT(mUserAgent, "Could not find field mUserAgent"); ALOG_ASSERT(mAcceptLanguage, "Could not find field mAcceptLanguage"); ALOG_ASSERT(mMinimumFontSize, "Could not find field mMinimumFontSize"); ALOG_ASSERT(mMinimumLogicalFontSize, "Could not find field mMinimumLogicalFontSize"); ALOG_ASSERT(mDefaultFontSize, "Could not find field mDefaultFontSize"); ALOG_ASSERT(mDefaultFixedFontSize, "Could not find field mDefaultFixedFontSize"); ALOG_ASSERT(mLoadsImagesAutomatically, "Could not find field mLoadsImagesAutomatically"); ALOG_ASSERT(mMediaPreloadEnabled, "Could not find field mMediaPreloadEnabled"); #ifdef ANDROID_BLOCK_NETWORK_IMAGE ALOG_ASSERT(mBlockNetworkImage, "Could not find field mBlockNetworkImage"); #endif ALOG_ASSERT(mBlockNetworkLoads, "Could not find field mBlockNetworkLoads"); ALOG_ASSERT(mJavaScriptEnabled, "Could not find field mJavaScriptEnabled"); ALOG_ASSERT(mAllowUniversalAccessFromFileURLs, "Could not find field mAllowUniversalAccessFromFileURLs"); ALOG_ASSERT(mAllowFileAccessFromFileURLs, "Could not find field mAllowFileAccessFromFileURLs"); ALOG_ASSERT(mPluginState, "Could not find field mPluginState"); #if ENABLE(OFFLINE_WEB_APPLICATIONS) ALOG_ASSERT(mAppCacheEnabled, "Could not find field mAppCacheEnabled"); ALOG_ASSERT(mAppCachePath, "Could not find field mAppCachePath"); ALOG_ASSERT(mAppCacheMaxSize, "Could not find field mAppCacheMaxSize"); #endif #if ENABLE(WORKERS) ALOG_ASSERT(mWorkersEnabled, "Could not find field mWorkersEnabled"); #endif ALOG_ASSERT(mJavaScriptCanOpenWindowsAutomatically, "Could not find field mJavaScriptCanOpenWindowsAutomatically"); ALOG_ASSERT(mUseWideViewport, "Could not find field mUseWideViewport"); ALOG_ASSERT(mSupportMultipleWindows, "Could not find field mSupportMultipleWindows"); ALOG_ASSERT(mShrinksStandaloneImagesToFit, "Could not find field mShrinksStandaloneImagesToFit"); ALOG_ASSERT(mMaximumDecodedImageSize, "Could not find field mMaximumDecodedImageSize"); ALOG_ASSERT(mUseDoubleTree, "Could not find field mUseDoubleTree"); ALOG_ASSERT(mPageCacheCapacity, "Could not find field mPageCacheCapacity"); ALOG_ASSERT(mPasswordEchoEnabled, "Could not find field mPasswordEchoEnabled"); jclass enumClass = env->FindClass("java/lang/Enum"); ALOG_ASSERT(enumClass, "Could not find Enum class!"); mOrdinal = env->GetMethodID(enumClass, "ordinal", "()I"); ALOG_ASSERT(mOrdinal, "Could not find method ordinal"); env->DeleteLocalRef(enumClass); }
bool RefBase::weakref_type::attemptIncStrong(const void* id) { incWeak(id); weakref_impl* const impl = static_cast<weakref_impl*>(this); int32_t curCount = impl->mStrong; ALOG_ASSERT(curCount >= 0, "attemptIncStrong called on %p after underflow", this); while (curCount > 0 && curCount != INITIAL_STRONG_VALUE) { if (android_atomic_cmpxchg(curCount, curCount+1, &impl->mStrong) == 0) { break; } curCount = impl->mStrong; } if (curCount <= 0 || curCount == INITIAL_STRONG_VALUE) { bool allow; if (curCount == INITIAL_STRONG_VALUE) { // Attempting to acquire first strong reference... this is allowed // if the object does NOT have a longer lifetime (meaning the // implementation doesn't need to see this), or if the implementation // allows it to happen. allow = (impl->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK || impl->mBase->onIncStrongAttempted(FIRST_INC_STRONG, id); } else { // Attempting to revive the object... this is allowed // if the object DOES have a longer lifetime (so we can safely // call the object with only a weak ref) and the implementation // allows it to happen. allow = (impl->mFlags&OBJECT_LIFETIME_WEAK) == OBJECT_LIFETIME_WEAK && impl->mBase->onIncStrongAttempted(FIRST_INC_STRONG, id); } if (!allow) { decWeak(id); return false; } curCount = android_atomic_inc(&impl->mStrong); // If the strong reference count has already been incremented by // someone else, the implementor of onIncStrongAttempted() is holding // an unneeded reference. So call onLastStrongRef() here to remove it. // (No, this is not pretty.) Note that we MUST NOT do this if we // are in fact acquiring the first reference. if (curCount > 0 && curCount < INITIAL_STRONG_VALUE) { impl->mBase->onLastStrongRef(id); } } impl->addStrongRef(id); #if PRINT_REFS ALOGD("attemptIncStrong of %p from %p: cnt=%d\n", this, id, curCount); #endif if (curCount == INITIAL_STRONG_VALUE) { android_atomic_add(-INITIAL_STRONG_VALUE, &impl->mStrong); impl->mBase->onFirstRef(); } return true; }
static void Sync(JNIEnv* env, jobject obj, jint frame) { WebCore::Frame* pFrame = (WebCore::Frame*)frame; ALOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__); WebCore::Settings* s = pFrame->settings(); if (!s) return; WebCore::CachedResourceLoader* cachedResourceLoader = pFrame->document()->cachedResourceLoader(); #ifdef ANDROID_LAYOUT jobject layout = env->GetObjectField(obj, gFieldIds->mLayoutAlgorithm); WebCore::Settings::LayoutAlgorithm l = (WebCore::Settings::LayoutAlgorithm) env->CallIntMethod(layout, gFieldIds->mOrdinal); if (s->layoutAlgorithm() != l) { s->setLayoutAlgorithm(l); if (pFrame->document()) { pFrame->document()->styleSelectorChanged(WebCore::RecalcStyleImmediately); if (pFrame->document()->renderer()) { recursiveCleanupForFullLayout(pFrame->document()->renderer()); ALOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout"); pFrame->view()->layout(); // FIXME: This call used to scroll the page to put the focus into view. // It worked on the WebViewCore, but now scrolling is done outside of the // WebViewCore, on the UI side, so there needs to be a new way to do this. //pFrame->makeFocusVisible(); } } } #endif jint textSize = env->GetIntField(obj, gFieldIds->mTextSize); float zoomFactor = textSize / 100.0f; if (pFrame->textZoomFactor() != zoomFactor) pFrame->setTextZoomFactor(zoomFactor); jstring str = (jstring)env->GetObjectField(obj, gFieldIds->mStandardFontFamily); s->setStandardFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mFixedFontFamily); s->setFixedFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mSansSerifFontFamily); s->setSansSerifFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mSerifFontFamily); s->setSerifFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mCursiveFontFamily); s->setCursiveFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mFantasyFontFamily); s->setFantasyFontFamily(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mDefaultTextEncoding); s->setDefaultTextEncodingName(jstringToWtfString(env, str)); str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgent); WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str)); WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent(); str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgentProfile); WebFrame::getWebFrame(pFrame)->setUserAgentProfile(jstringToWtfString(env, str)); WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgentProfile(); jint cacheMode = env->GetIntField(obj, gFieldIds->mOverrideCacheMode); WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextCacheMode(cacheMode); str = (jstring)env->GetObjectField(obj, gFieldIds->mAcceptLanguage); WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str)); jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize); s->setMinimumFontSize(size); size = env->GetIntField(obj, gFieldIds->mMinimumLogicalFontSize); s->setMinimumLogicalFontSize(size); size = env->GetIntField(obj, gFieldIds->mDefaultFontSize); s->setDefaultFontSize(size); size = env->GetIntField(obj, gFieldIds->mDefaultFixedFontSize); s->setDefaultFixedFontSize(size); jboolean flag = env->GetBooleanField(obj, gFieldIds->mLoadsImagesAutomatically); s->setLoadsImagesAutomatically(flag); if (flag) cachedResourceLoader->setAutoLoadImages(true); flag = env->GetBooleanField(obj, gFieldIds->mMediaPreloadEnabled); s->setMediaPreloadEnabled(flag); #ifdef ANDROID_BLOCK_NETWORK_IMAGE flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkImage); s->setBlockNetworkImage(flag); if(!flag) cachedResourceLoader->setBlockNetworkImage(false); #endif flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkLoads); WebFrame* webFrame = WebFrame::getWebFrame(pFrame); webFrame->setBlockNetworkLoads(flag); flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled); s->setJavaScriptEnabled(flag); flag = env->GetBooleanField(obj, gFieldIds->mAllowUniversalAccessFromFileURLs); s->setAllowUniversalAccessFromFileURLs(flag); flag = env->GetBooleanField(obj, gFieldIds->mAllowFileAccessFromFileURLs); s->setAllowFileAccessFromFileURLs(flag); // Hyperlink auditing (the ping attribute) has similar privacy // considerations as does the running of JavaScript, so to keep the UI // simpler, we leverage the same setting. s->setHyperlinkAuditingEnabled(flag); // ON = 0 // ON_DEMAND = 1 // OFF = 2 jobject pluginState = env->GetObjectField(obj, gFieldIds->mPluginState); int state = env->CallIntMethod(pluginState, gFieldIds->mOrdinal); s->setPluginsEnabled(state < 2); #ifdef ANDROID_PLUGINS s->setPluginsOnDemand(state == 1); #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) // We only enable AppCache if it's been enabled with a call to // setAppCacheEnabled() and if a valid path has been supplied to // setAppCachePath(). Note that the path is applied to all WebViews // whereas enabling is applied per WebView. // WebCore asserts that the path is only set once. Since the path is // shared between WebViews, we can't do the required checks to guard // against this in the Java WebSettings. bool isPathValid = false; if (cacheStorage().cacheDirectory().isNull()) { str = static_cast<jstring>(env->GetObjectField(obj, gFieldIds->mAppCachePath)); // Check for non-null string as an optimization, as this is the common case. if (str) { String path = jstringToWtfString(env, str); ALOG_ASSERT(!path.empty(), "Java side should never send empty string for AppCache path"); // This database is created on the first load. If the file // doesn't exist, we create it and set its permissions. The // filename must match that in ApplicationCacheStorage.cpp. String filename = pathByAppendingComponent(path, "ApplicationCache.db"); int fd = open(filename.utf8().data(), O_CREAT, permissionFlags660); if (fd >= 0) { close(fd); cacheStorage().setCacheDirectory(path); isPathValid = true; } } } else isPathValid = true; flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled); s->setOfflineWebApplicationCacheEnabled(flag && isPathValid); jlong maxsize = env->GetLongField(obj, gFieldIds->mAppCacheMaxSize); cacheStorage().setMaximumSize(maxsize); #endif flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptCanOpenWindowsAutomatically); s->setJavaScriptCanOpenWindowsAutomatically(flag); #ifdef ANDROID_LAYOUT flag = env->GetBooleanField(obj, gFieldIds->mUseWideViewport); s->setUseWideViewport(flag); #endif #ifdef ANDROID_MULTIPLE_WINDOWS flag = env->GetBooleanField(obj, gFieldIds->mSupportMultipleWindows); s->setSupportMultipleWindows(flag); #endif flag = env->GetBooleanField(obj, gFieldIds->mShrinksStandaloneImagesToFit); s->setShrinksStandaloneImagesToFit(flag); jlong maxImage = env->GetLongField(obj, gFieldIds->mMaximumDecodedImageSize); // Since in ImageSourceAndroid.cpp, the image will always not exceed // MAX_SIZE_BEFORE_SUBSAMPLE, there's no need to pass the max value to // WebCore, which checks (image_width * image_height * 4) as an // estimation against the max value, which is done in CachedImage.cpp. // And there're cases where the decoded image size will not // exceed the max, but the WebCore estimation will. So the following // code is commented out to fix those cases. // if (maxImage == 0) // maxImage = computeMaxBitmapSizeForCache(); s->setMaximumDecodedImageSize(maxImage); flag = env->GetBooleanField(obj, gFieldIds->mPrivateBrowsingEnabled); s->setPrivateBrowsingEnabled(flag); flag = env->GetBooleanField(obj, gFieldIds->mSyntheticLinksEnabled); s->setDefaultFormatDetection(flag); s->setFormatDetectionAddress(flag); s->setFormatDetectionEmail(flag); s->setFormatDetectionTelephone(flag); #if ENABLE(DATABASE) flag = env->GetBooleanField(obj, gFieldIds->mDatabaseEnabled); WebCore::Database::setIsAvailable(flag); flag = env->GetBooleanField(obj, gFieldIds->mDatabasePathHasBeenSet); if (flag) { // If the user has set the database path, sync it to the DatabaseTracker. str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); if (str) { String path = jstringToWtfString(env, str); DatabaseTracker::tracker().setDatabaseDirectoryPath(path); // This database is created when the first HTML5 Database object is // instantiated. If the file doesn't exist, we create it and set its // permissions. The filename must match that in // DatabaseTracker.cpp. String filename = SQLiteFileSystem::appendDatabaseFileNameToPath(path, "Databases.db"); int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); if (fd >= 0) close(fd); } } #endif #if ENABLE(DOM_STORAGE) flag = env->GetBooleanField(obj, gFieldIds->mDomStorageEnabled); s->setLocalStorageEnabled(flag); str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); if (str) { WTF::String localStorageDatabasePath = jstringToWtfString(env,str); if (localStorageDatabasePath.length()) { localStorageDatabasePath = WebCore::pathByAppendingComponent( localStorageDatabasePath, "localstorage"); // We need 770 for folders mkdir(localStorageDatabasePath.utf8().data(), permissionFlags660 | S_IXUSR | S_IXGRP); s->setLocalStorageDatabasePath(localStorageDatabasePath); } } #endif flag = env->GetBooleanField(obj, gFieldIds->mGeolocationEnabled); GeolocationPermissions::setAlwaysDeny(!flag); str = (jstring)env->GetObjectField(obj, gFieldIds->mGeolocationDatabasePath); if (str) { String path = jstringToWtfString(env, str); GeolocationPermissions::setDatabasePath(path); GeolocationPositionCache::instance()->setDatabasePath(path); // This database is created when the first Geolocation object is // instantiated. If the file doesn't exist, we create it and set its // permissions. The filename must match that in // GeolocationPositionCache.cpp. String filename = SQLiteFileSystem::appendDatabaseFileNameToPath(path, "CachedGeoposition.db"); int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660); if (fd >= 0) close(fd); } flag = env->GetBooleanField(obj, gFieldIds->mXSSAuditorEnabled); s->setXSSAuditorEnabled(flag); #if ENABLE(LINK_PREFETCH) flag = env->GetBooleanField(obj, gFieldIds->mLinkPrefetchEnabled); s->setLinkPrefetchEnabled(flag); #endif size = env->GetIntField(obj, gFieldIds->mPageCacheCapacity); if (size > 0) { s->setUsesPageCache(true); WebCore::pageCache()->setCapacity(size); } else s->setUsesPageCache(false); #if ENABLE(WEB_AUTOFILL) flag = env->GetBooleanField(obj, gFieldIds->mAutoFillEnabled); // TODO: This updates the Settings WebCore side with the user's // preference for autofill and will stop WebCore making requests // into the chromium autofill code. That code in Chromium also has // a notion of being enabled/disabled that gets read from the users // preferences. At the moment, it's hardcoded to true on Android // (see chrome/browser/autofill/autofill_manager.cc:405). This // setting should probably be synced into Chromium also. s->setAutoFillEnabled(flag); if (flag) { EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(pFrame->page()->editorClient()); WebAutofill* webAutofill = editorC->getAutofill(); // Set the active AutofillProfile data. jobject autoFillProfile = env->GetObjectField(obj, gFieldIds->mAutoFillProfile); if (autoFillProfile) syncAutoFillProfile(env, autoFillProfile, webAutofill); else { // The autofill profile is null. We need to tell Chromium about this because // this may be because the user just deleted their profile but left the // autofill feature setting enabled. webAutofill->clearProfiles(); } } #endif // This is required to enable the XMLTreeViewer when loading an XML document that // has no style attached to it. http://trac.webkit.org/changeset/79799 s->setDeveloperExtrasEnabled(true); s->setSpatialNavigationEnabled(true); bool echoPassword = env->GetBooleanField(obj, gFieldIds->mPasswordEchoEnabled); s->setPasswordEchoEnabled(echoPassword); }
WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest) : m_webFrame(webFrame) , m_resourceHandle(resourceHandle) , m_isMainResource(false) , m_isMainFrame(false) , m_isCertMimeType(false) , m_cancelling(false) , m_sync(false) , m_finished(false) { m_webFrame->ref(); bool block = webFrame->blockNetworkLoads() && (resourceRequest.url().protocolIs("http") || resourceRequest.url().protocolIs("https")); WebResourceRequest webResourceRequest(resourceRequest, block); UrlInterceptResponse* intercept = webFrame->shouldInterceptRequest(resourceRequest.url().string()); if (intercept) { m_request = new WebRequest(this, webResourceRequest, intercept); return; } m_request = new WebRequest(this, webResourceRequest); // Set uploads before start is called on the request if (resourceRequest.httpBody() && !(webResourceRequest.method() == "GET" || webResourceRequest.method() == "HEAD")) { Vector<FormDataElement>::iterator iter; Vector<FormDataElement> elements = resourceRequest.httpBody()->elements(); for (iter = elements.begin(); iter != elements.end(); iter++) { FormDataElement element = *iter; switch (element.m_type) { case FormDataElement::data: if (!element.m_data.isEmpty()) { // WebKit sometimes gives up empty data to append. These aren't // necessary so we just optimize those out here. base::Thread* thread = ioThread(); if (thread) { Vector<char>* data = new Vector<char>(element.m_data); thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::appendBytesToUpload, data)); } } break; case FormDataElement::encodedFile: { // Chromium check if it is a directory by checking // element.m_fileLength, that doesn't work in Android std::string filename = element.m_filename.utf8().data(); if (filename.size()) { // Change from a url string to a filename if (filename.find("file://") == 0) // Found at pos 0 filename.erase(0, 7); base::Thread* thread = ioThread(); if (thread) thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::appendFileToUpload, filename)); } } break; #if ENABLE(BLOB) case FormDataElement::encodedBlob: ALOG_ASSERT(false, "Unexpected use of FormDataElement::encodedBlob"); break; #endif // ENABLE(BLOB) default: ALOG_ASSERT(false, "Unexpected default case in WebUrlLoaderClient.cpp"); break; } } } }
void FastCapture::onStateChange() { const FastCaptureState * const current = (const FastCaptureState *) mCurrent; const FastCaptureState * const previous = (const FastCaptureState *) mPrevious; FastCaptureDumpState * const dumpState = (FastCaptureDumpState *) mDumpState; const size_t frameCount = current->mFrameCount; bool eitherChanged = false; // check for change in input HAL configuration NBAIO_Format previousFormat = mFormat; if (current->mInputSourceGen != mInputSourceGen) { mInputSource = current->mInputSource; mInputSourceGen = current->mInputSourceGen; if (mInputSource == NULL) { mFormat = Format_Invalid; mSampleRate = 0; } else { mFormat = mInputSource->format(); mSampleRate = Format_sampleRate(mFormat); unsigned channelCount = Format_channelCount(mFormat); ALOG_ASSERT(channelCount >= 1 && channelCount <= FCC_8); } dumpState->mSampleRate = mSampleRate; eitherChanged = true; } // check for change in pipe if (current->mPipeSinkGen != mPipeSinkGen) { mPipeSink = current->mPipeSink; mPipeSinkGen = current->mPipeSinkGen; eitherChanged = true; } // input source and pipe sink must be compatible if (eitherChanged && mInputSource != NULL && mPipeSink != NULL) { ALOG_ASSERT(Format_isEqual(mFormat, mPipeSink->format())); } if ((!Format_isEqual(mFormat, previousFormat)) || (frameCount != previous->mFrameCount)) { // FIXME to avoid priority inversion, don't free here free(mReadBuffer); mReadBuffer = NULL; if (frameCount > 0 && mSampleRate > 0) { // FIXME new may block for unbounded time at internal mutex of the heap // implementation; it would be better to have normal capture thread allocate for // us to avoid blocking here and to prevent possible priority inversion (void)posix_memalign(&mReadBuffer, 32, frameCount * Format_frameSize(mFormat)); mPeriodNs = (frameCount * 1000000000LL) / mSampleRate; // 1.00 mUnderrunNs = (frameCount * 1750000000LL) / mSampleRate; // 1.75 mOverrunNs = (frameCount * 500000000LL) / mSampleRate; // 0.50 mForceNs = (frameCount * 950000000LL) / mSampleRate; // 0.95 mWarmupNsMin = (frameCount * 750000000LL) / mSampleRate; // 0.75 mWarmupNsMax = (frameCount * 1250000000LL) / mSampleRate; // 1.25 } else { mPeriodNs = 0; mUnderrunNs = 0; mOverrunNs = 0; mForceNs = 0; mWarmupNsMin = 0; mWarmupNsMax = LONG_MAX; } mReadBufferState = -1; dumpState->mFrameCount = frameCount; } }
size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) { ALOG_ASSERT(bufferSize >= 1); AutoMutex _l(mLock); struct input_event readBuffer[bufferSize]; RawEvent* event = buffer; size_t capacity = bufferSize; bool awoken = false; for (;;) { nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); // Reopen input devices if needed. if (mNeedToReopenDevices) { mNeedToReopenDevices = false; ALOGI("Reopening all input devices due to a configuration change."); closeAllDevicesLocked(); mNeedToScanDevices = true; break; // return to the caller before we actually rescan } // Report any devices that had last been added/removed. while (mClosingDevices) { Device* device = mClosingDevices; ALOGV("Reporting device closed: id=%d, name=%s\n", device->id, device->path.string()); mClosingDevices = device->next; event->when = now; event->deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id; event->type = DEVICE_REMOVED; event += 1; delete device; mNeedToSendFinishedDeviceScan = true; if (--capacity == 0) { break; } } if (mNeedToScanDevices) { mNeedToScanDevices = false; scanDevicesLocked(); mNeedToSendFinishedDeviceScan = true; } while (mOpeningDevices != NULL) { Device* device = mOpeningDevices; ALOGV("Reporting device opened: id=%d, name=%s\n", device->id, device->path.string()); mOpeningDevices = device->next; event->when = now; event->deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id; event->type = DEVICE_ADDED; event += 1; mNeedToSendFinishedDeviceScan = true; if (--capacity == 0) { break; } } if (mNeedToSendFinishedDeviceScan) { mNeedToSendFinishedDeviceScan = false; event->when = now; event->type = FINISHED_DEVICE_SCAN; event += 1; if (--capacity == 0) { break; } } // Grab the next input event. bool deviceChanged = false; while (mPendingEventIndex < mPendingEventCount) { const struct epoll_event& eventItem = mPendingEventItems[mPendingEventIndex++]; if (eventItem.data.u32 == EPOLL_ID_INOTIFY) { if (eventItem.events & EPOLLIN) { mPendingINotify = true; } else { ALOGW("Received unexpected epoll event 0x%08x for INotify.", eventItem.events); } continue; } if (eventItem.data.u32 == EPOLL_ID_WAKE) { if (eventItem.events & EPOLLIN) { ALOGV("awoken after wake()"); awoken = true; char buffer[16]; ssize_t nRead; do { nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer)); } while ((nRead == -1 && errno == EINTR) || nRead == sizeof(buffer)); } else { ALOGW("Received unexpected epoll event 0x%08x for wake read pipe.", eventItem.events); } continue; } ssize_t deviceIndex = mDevices.indexOfKey(eventItem.data.u32); if (deviceIndex < 0) { ALOGW("Received unexpected epoll event 0x%08x for unknown device id %d.", eventItem.events, eventItem.data.u32); continue; } Device* device = mDevices.valueAt(deviceIndex); if (eventItem.events & EPOLLIN) { int32_t readSize = read(device->fd, readBuffer, sizeof(struct input_event) * capacity); if (readSize == 0 || (readSize < 0 && errno == ENODEV)) { // Device was removed before INotify noticed. ALOGW("could not get event, removed? (fd: %d size: %d bufferSize: %d capacity: %d errno: %d)\n", device->fd, readSize, bufferSize, capacity, errno); deviceChanged = true; closeDeviceLocked(device); } else if (readSize < 0) { if (errno != EAGAIN && errno != EINTR) { ALOGW("could not get event (errno=%d)", errno); } } else if ((readSize % sizeof(struct input_event)) != 0) { ALOGE("could not get event (wrong size: %d)", readSize); } else { int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id; size_t count = size_t(readSize) / sizeof(struct input_event); for (size_t i = 0; i < count; i++) { const struct input_event& iev = readBuffer[i]; ALOGV("%s got: t0=%d, t1=%d, type=%d, code=%d, value=%d", device->path.string(), (int) iev.time.tv_sec, (int) iev.time.tv_usec, iev.type, iev.code, iev.value); #ifdef HAVE_POSIX_CLOCKS // Use the time specified in the event instead of the current time // so that downstream code can get more accurate estimates of // event dispatch latency from the time the event is enqueued onto // the evdev client buffer. // // The event's timestamp fortuitously uses the same monotonic clock // time base as the rest of Android. The kernel event device driver // (drivers/input/evdev.c) obtains timestamps using ktime_get_ts(). // The systemTime(SYSTEM_TIME_MONOTONIC) function we use everywhere // calls clock_gettime(CLOCK_MONOTONIC) which is implemented as a // system call that also queries ktime_get_ts(). event->when = nsecs_t(iev.time.tv_sec) * 1000000000LL + nsecs_t(iev.time.tv_usec) * 1000LL; ALOGV("event time %lld, now %lld", event->when, now); #else event->when = now; #endif event->deviceId = deviceId; event->type = iev.type; event->scanCode = iev.code; event->value = iev.value; event->keyCode = AKEYCODE_UNKNOWN; event->flags = 0; if (iev.type == EV_KEY && device->keyMap.haveKeyLayout()) { status_t err = device->keyMap.keyLayoutMap->mapKey(iev.code, &event->keyCode, &event->flags); ALOGV("iev.code=%d keyCode=%d flags=0x%08x err=%d\n", iev.code, event->keyCode, event->flags, err); } event += 1; } capacity -= count; if (capacity == 0) { // The result buffer is full. Reset the pending event index // so we will try to read the device again on the next iteration. mPendingEventIndex -= 1; break; } } } else { ALOGW("Received unexpected epoll event 0x%08x for device %s.", eventItem.events, device->identifier.name.string()); } } // readNotify() will modify the list of devices so this must be done after // processing all other events to ensure that we read all remaining events // before closing the devices. if (mPendingINotify && mPendingEventIndex >= mPendingEventCount) { mPendingINotify = false; readNotifyLocked(); deviceChanged = true; } // Report added or removed devices immediately. if (deviceChanged) { continue; } // Return now if we have collected any events or if we were explicitly awoken. if (event != buffer || awoken) { break; } // Poll for events. Mind the wake lock dance! // We hold a wake lock at all times except during epoll_wait(). This works due to some // subtle choreography. When a device driver has pending (unread) events, it acquires // a kernel wake lock. However, once the last pending event has been read, the device // driver will release the kernel wake lock. To prevent the system from going to sleep // when this happens, the EventHub holds onto its own user wake lock while the client // is processing events. Thus the system can only sleep if there are no events // pending or currently being processed. // // The timeout is advisory only. If the device is asleep, it will not wake just to // service the timeout. mPendingEventIndex = 0; mLock.unlock(); // release lock before poll, must be before release_wake_lock release_wake_lock(WAKE_LOCK_ID); int pollResult = epoll_wait(mEpollFd, mPendingEventItems, EPOLL_MAX_EVENTS, timeoutMillis); acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID); mLock.lock(); // reacquire lock after poll, must be after acquire_wake_lock if (pollResult == 0) { // Timed out. mPendingEventCount = 0; break; } if (pollResult < 0) { // An error occurred. mPendingEventCount = 0; // Sleep after errors to avoid locking up the system. // Hopefully the error is transient. if (errno != EINTR) { ALOGW("poll failed (errno=%d)\n", errno); usleep(100000); } } else { // Some events occurred. mPendingEventCount = size_t(pollResult); // On an SMP system, it is possible for the framework to read input events // faster than the kernel input device driver can produce a complete packet. // Because poll() wakes up as soon as the first input event becomes available, // the framework will often end up reading one event at a time until the // packet is complete. Instead of one call to read() returning 71 events, // it could take 71 calls to read() each returning 1 event. // // Sleep for a short period of time after waking up from the poll() to give // the kernel time to finish writing the entire packet of input events. if (mNumCpus > 1) { usleep(250); } } } // All done, return the number of events we read. return event - buffer; }
static bool readItemRecursive(WebCore::HistoryItem* newItem, const char** pData, int length) { if (!pData || length < HISTORY_MIN_SIZE) { ALOGW("readItemRecursive() bad params; pData=%p length=%d", pData, length); return false; } const char* data = *pData; const char* end = data + length; String content; // Read the original url if (readString(data, end, content, "Original url")) newItem->setOriginalURLString(content); else return false; // Read the url if (readString(data, end, content, "Url")) newItem->setURLString(content); else return false; // Read the title if (readString(data, end, content, "Title")) newItem->setTitle(content); else return false; // Generate a new ResourceRequest object for populating form information. // Read the form content type WTF::String formContentType; if (!readString(data, end, formContentType, "Content type")) return false; // Read the form data size unsigned formDataSize; if (!readUnsigned(data, end, formDataSize, "Form data size")) return false; // Read the form data WTF::RefPtr<WebCore::FormData> formData; if (formDataSize) { ALOGV("Reading Form data %d %.*s", formDataSize, formDataSize, data); if ((end < data) || ((size_t)(end - data) < formDataSize)) { ALOGW("\tNot enough data to read form data; returning"); return false; } formData = WebCore::FormData::create(data, formDataSize); data += formDataSize; // Read the identifier int64_t id; if (!readInt64(data, end, id, "Form id")) return false; if (id){ if (formData != NULL){ formData->setIdentifier(id); }else { //LOGD("read_item_recursive create formData is null"); } } /*guoxiaolei 20120827 end>*/ } // Set up the form info if (formData != NULL) { WebCore::ResourceRequest r; r.setHTTPMethod("POST"); r.setHTTPContentType(formContentType); r.setHTTPBody(formData); newItem->setFormInfoFromRequest(r); } // Read the target if (readString(data, end, content, "Target")) newItem->setTarget(content); else return false; AndroidWebHistoryBridge* bridge = newItem->bridge(); ALOG_ASSERT(bridge, "There should be a bridge object during inflate"); // Read the screen scale float fValue; if (readFloat(data, end, fValue, "Screen scale")) bridge->setScale(fValue); else return false; // Read the text wrap scale if (readFloat(data, end, fValue, "Text wrap scale")) bridge->setTextWrapScale(fValue); else return false; // Read scroll position. int scrollX; if (!readInt(data, end, scrollX, "Scroll pos x")) return false; int scrollY; if (!readInt(data, end, scrollY, "Scroll pos y")) return false; newItem->setScrollPoint(IntPoint(scrollX, scrollY)); // Read the document state unsigned docStateCount; if (!readUnsigned(data, end, docStateCount, "Doc state count")) return false; if (docStateCount) { // Create a new vector and reserve enough space for the document state. WTF::Vector<WTF::String> docState; docState.reserveCapacity(docStateCount); while (docStateCount--) { // Read a document state string if (readString(data, end, content, "Document state")) docState.append(content); else return false; } newItem->setDocumentState(docState); } // Read is target item bool c; if (readBool(data, end, c, "Target item")) newItem->setIsTargetItem(c); else return false; // Read the child count unsigned count; if (!readUnsigned(data, end, count, "Child count")) return false; *pData = data; if (count) { while (count--) { // No need to check the length each time because read_item_recursive // will return null if there isn't enough data left to parse. WTF::RefPtr<WebCore::HistoryItem> child = WebCore::HistoryItem::create(); // Set a bridge that will not call into java. child->setBridge(new WebHistoryItem(static_cast<WebHistoryItem*>(bridge))); // Read the child item. if (!readItemRecursive(child.get(), pData, end - data)) return false; child->bridge()->setActive(); newItem->addChildItem(child); } } return true; }
bool RefBase::weakref_type::attemptIncStrong(const void* id) { incWeak(id); weakref_impl* const impl = static_cast<weakref_impl*>(this); int32_t curCount = impl->mStrong.load(std::memory_order_relaxed); ALOG_ASSERT(curCount >= 0, "attemptIncStrong called on %p after underflow", this); while (curCount > 0 && curCount != INITIAL_STRONG_VALUE) { // we're in the easy/common case of promoting a weak-reference // from an existing strong reference. if (impl->mStrong.compare_exchange_weak(curCount, curCount+1, std::memory_order_relaxed)) { break; } // the strong count has changed on us, we need to re-assert our // situation. curCount was updated by compare_exchange_weak. } if (curCount <= 0 || curCount == INITIAL_STRONG_VALUE) { // we're now in the harder case of either: // - there never was a strong reference on us // - or, all strong references have been released int32_t flags = impl->mFlags.load(std::memory_order_relaxed); if ((flags&OBJECT_LIFETIME_MASK) == OBJECT_LIFETIME_STRONG) { // this object has a "normal" life-time, i.e.: it gets destroyed // when the last strong reference goes away if (curCount <= 0) { // the last strong-reference got released, the object cannot // be revived. decWeak(id); return false; } // here, curCount == INITIAL_STRONG_VALUE, which means // there never was a strong-reference, so we can try to // promote this object; we need to do that atomically. while (curCount > 0) { if (impl->mStrong.compare_exchange_weak(curCount, curCount+1, std::memory_order_relaxed)) { break; } // the strong count has changed on us, we need to re-assert our // situation (e.g.: another thread has inc/decStrong'ed us) // curCount has been updated. } if (curCount <= 0) { // promote() failed, some other thread destroyed us in the // meantime (i.e.: strong count reached zero). decWeak(id); return false; } } else { // this object has an "extended" life-time, i.e.: it can be // revived from a weak-reference only. // Ask the object's implementation if it agrees to be revived if (!impl->mBase->onIncStrongAttempted(FIRST_INC_STRONG, id)) { // it didn't so give-up. decWeak(id); return false; } // grab a strong-reference, which is always safe due to the // extended life-time. curCount = impl->mStrong.fetch_add(1, std::memory_order_relaxed); // If the strong reference count has already been incremented by // someone else, the implementor of onIncStrongAttempted() is holding // an unneeded reference. So call onLastStrongRef() here to remove it. // (No, this is not pretty.) Note that we MUST NOT do this if we // are in fact acquiring the first reference. if (curCount != 0 && curCount != INITIAL_STRONG_VALUE) { impl->mBase->onLastStrongRef(id); } } } impl->addStrongRef(id); #if PRINT_REFS ALOGD("attemptIncStrong of %p from %p: cnt=%d\n", this, id, curCount); #endif // curCount is the value of mStrong before we incremented it. // Now we need to fix-up the count if it was INITIAL_STRONG_VALUE. // This must be done safely, i.e.: handle the case where several threads // were here in attemptIncStrong(). // curCount > INITIAL_STRONG_VALUE is OK, and can happen if we're doing // this in the middle of another incStrong. The subtraction is handled // by the thread that started with INITIAL_STRONG_VALUE. if (curCount == INITIAL_STRONG_VALUE) { impl->mStrong.fetch_sub(INITIAL_STRONG_VALUE, std::memory_order_relaxed); } return true; }
static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame) { ALOG_ASSERT(frame, "Close needs a valid Frame pointer!"); WebCore::Frame* pFrame = (WebCore::Frame*)frame; WebCore::BackForwardListImpl* list = static_cast<WebCore::BackForwardListImpl*>(pFrame->page()->backForwardList()); RefPtr<WebCore::HistoryItem> current = list->currentItem(); // Remove each item instead of using close(). close() is intended to be used // right before the list is deleted. WebCore::HistoryItemVector& entries = list->entries(); int size = entries.size(); for (int i = size - 1; i >= 0; --i) list->removeItem(entries[i].get()); // Add the current item back to the list. if (current) { current->setBridge(0); // addItem will update the children to match the newly created bridge list->addItem(current); /* * The Grand Prix site uses anchor navigations to change the display. * WebKit tries to be smart and not load child frames that have the * same history urls during an anchor navigation. This means that the * current history item stored in the child frame's loader does not * match the item found in the history tree. If we remove all the * entries in the back/foward list, we have to restore the entire tree * or else a HistoryItem might have a deleted parent. * * In order to restore the history tree correctly, we have to look up * all the frames first and then look up the history item. We do this * because the history item in the tree may be null at this point. * Unfortunately, a HistoryItem can only search its immediately * children so we do a breadth-first rebuild of the tree. */ // Keep a small list of child frames to traverse. WTF::Vector<WebCore::Frame*> frameQueue; // Fix the top-level item. pFrame->loader()->history()->setCurrentItem(current.get()); WebCore::Frame* child = pFrame->tree()->firstChild(); // Remember the parent history item so we can search for a child item. RefPtr<WebCore::HistoryItem> parent = current; while (child) { // Use the old history item since the current one may have a // deleted parent. WebCore::HistoryItem* item = parent->childItemWithTarget(child->tree()->name()); child->loader()->history()->setCurrentItem(item); // Append the first child to the queue if it exists. If there is no // item, then we do not need to traverse the children since there // will be no parent history item. WebCore::Frame* firstChild; if (item && (firstChild = child->tree()->firstChild())) frameQueue.append(firstChild); child = child->tree()->nextSibling(); // If we don't have a sibling for this frame and the queue isn't // empty, use the next entry in the queue. if (!child && !frameQueue.isEmpty()) { child = frameQueue.at(0); frameQueue.remove(0); // Figure out the parent history item used when searching for // the history item to use. parent = child->tree()->parent()->loader()->history()->currentItem(); } } } }
const Point& Quad::point(int ix) const { ALOG_ASSERT(ix < static_cast<int>(points_.size()), "Access out of bounds"); return points_[ix]; }
// BufferQueue::ConsumerListener callback void GraphicBufferSource::onSidebandStreamChanged() { ALOG_ASSERT(false, "GraphicBufferSource can't consume sideband streams"); }