Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2264)

Unified Diff: android_webview/native/aw_renderer_priority_manager.cc

Issue 2650753002: Implement renderer importance API for WebView (Closed)
Patch Set: clean up unused local Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_renderer_priority_manager.cc
diff --git a/android_webview/native/aw_renderer_priority_manager.cc b/android_webview/native/aw_renderer_priority_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c19f32336e5e9df60184b5b4a0ca7df22f13dd5c
--- /dev/null
+++ b/android_webview/native/aw_renderer_priority_manager.cc
@@ -0,0 +1,42 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/native/aw_renderer_priority_manager.h"
+
+#include "base/android/jni_android.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "jni/AwRendererPriorityManager_jni.h"
+
+namespace android_webview {
+
+AwRendererPriorityManager::AwRendererPriorityManager(
+ content::RenderProcessHost* host)
+ : host_(host), renderer_priority_(RENDERER_PRIORITY_INITIAL) {}
+
+void AwRendererPriorityManager::SetRendererPriority(
+ RendererPriority renderer_priority) {
+ if (host_->GetHandle() == 0) {
+ return;
+ }
+ if (renderer_priority_ != renderer_priority) {
+ renderer_priority_ = renderer_priority;
+ content::BrowserThread::PostTask(
+ content::BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
+ base::Bind(&SetRendererPriorityOnLauncherThread, host_->GetHandle(),
+ renderer_priority_));
+ }
+}
+
+// static
+void AwRendererPriorityManager::SetRendererPriorityOnLauncherThread(
+ int pid,
+ RendererPriority renderer_priority) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ DCHECK(env);
+ Java_AwRendererPriorityManager_setRendererPriority(
+ env, static_cast<jint>(pid), static_cast<jint>(renderer_priority));
+}
+
+} // namespace android_webview
« no previous file with comments | « android_webview/native/aw_renderer_priority_manager.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698