| 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)
|
|
|