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

Unified Diff: android_webview/native/aw_contents_io_thread_client_impl.cc

Issue 1544863002: [Android WebView] Implement initial settings and callback support for Service Workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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_contents_io_thread_client_impl.cc
diff --git a/android_webview/native/aw_contents_io_thread_client_impl.cc b/android_webview/native/aw_contents_io_thread_client_impl.cc
index 674832dce1d2a5d0c2481cb8662b96504ec026d5..79dc0844e86a362dc24d3b82010bdb53ebcbefc0 100644
--- a/android_webview/native/aw_contents_io_thread_client_impl.cc
+++ b/android_webview/native/aw_contents_io_thread_client_impl.cc
@@ -85,6 +85,10 @@ LazyInstance<RfhToIoThreadClientMap> RfhToIoThreadClientMap::g_instance_ =
LAZY_INSTANCE_INITIALIZER;
// static
+LazyInstance<JavaObjectWeakGlobalRef> g_sw_instance_ =
+ LAZY_INSTANCE_INITIALIZER;
+
+// static
RfhToIoThreadClientMap* RfhToIoThreadClientMap::GetInstance() {
return g_instance_.Pointer();
}
@@ -254,6 +258,31 @@ void AwContentsIoThreadClientImpl::Associate(
new ClientMapEntryUpdater(env, web_contents, jclient.obj());
}
+// static
+void AwContentsIoThreadClientImpl::SetServiceWorkerIoThreadClient(
+ const base::android::JavaRef<jobject>& jclient,
+ const base::android::JavaRef<jobject>& browser_context) {
+ // TODO: currently there is only one browser context so it is ok to
+ // store in a global variable, in the future use browser_context to
+ // obtain the correct instance.
+ JavaObjectWeakGlobalRef temp(AttachCurrentThread(), jclient.obj());
+ g_sw_instance_.Get() = temp;
+}
+
+// static
+scoped_ptr<AwContentsIoThreadClient>
+AwContentsIoThreadClient::GetServiceWorkerIoThreadClient() {
+ if (g_sw_instance_.Get().is_empty())
+ return scoped_ptr<AwContentsIoThreadClient>();
+
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> java_delegate = g_sw_instance_.Get().get(env);
+
+ DCHECK(!java_delegate.is_null());
+ return scoped_ptr<AwContentsIoThreadClient>(new AwContentsIoThreadClientImpl(
+ false, java_delegate));
+}
+
AwContentsIoThreadClientImpl::AwContentsIoThreadClientImpl(
bool pending_association,
const JavaRef<jobject>& obj)
« no previous file with comments | « android_webview/native/aw_contents_io_thread_client_impl.h ('k') | android_webview/native/aw_contents_statics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698