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

Unified Diff: android_webview/browser/net/aw_request_interceptor.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/browser/net/aw_request_interceptor.cc
diff --git a/android_webview/browser/net/aw_request_interceptor.cc b/android_webview/browser/net/aw_request_interceptor.cc
index 30ae888793ad4ec98ef57a42f7d7d574c6055586..9aa6a2a40ab7ac3a769683b6ed7798b0ed529021 100644
--- a/android_webview/browser/net/aw_request_interceptor.cc
+++ b/android_webview/browser/net/aw_request_interceptor.cc
@@ -114,6 +114,29 @@ class ShouldInterceptRequestAdaptor
DISALLOW_COPY_AND_ASSIGN(ShouldInterceptRequestAdaptor);
};
+scoped_ptr<AwContentsIoThreadClient> GetCorrespondingIoThreadClient(
+ net::URLRequest* request) {
+ int render_process_id, render_frame_id;
+ if (!content::ResourceRequestInfo::GetRenderFrameForRequest(
+ request, &render_process_id, &render_frame_id)) {
+ // When there is no associated render frame, or the frame_id is
+ // invalid we assume the request come from a service worker.
+ // TODO: add a more explicit service worker check.
+ return AwContentsIoThreadClient::GetServiceWorkerIoThreadClient();
+ }
+
+ scoped_ptr<AwContentsIoThreadClient> io_thread_client =
+ AwContentsIoThreadClient::FromID(render_process_id, render_frame_id);
+
+ if (!io_thread_client) {
+ // This means the frame id is invalid/not set, this currently happens
+ // with e.g. fetch requests coming from service workers.
+ return AwContentsIoThreadClient::GetServiceWorkerIoThreadClient();
+ }
+
+ return io_thread_client;
+}
+
} // namespace
AwRequestInterceptor::AwRequestInterceptor() {}
@@ -129,14 +152,8 @@ net::URLRequestJob* AwRequestInterceptor::MaybeInterceptRequest(
if (request->GetUserData(kRequestAlreadyHasJobDataKey))
return nullptr;
- int render_process_id, render_frame_id;
- if (!content::ResourceRequestInfo::GetRenderFrameForRequest(
- request, &render_process_id, &render_frame_id)) {
- return nullptr;
- }
-
scoped_ptr<AwContentsIoThreadClient> io_thread_client =
- AwContentsIoThreadClient::FromID(render_process_id, render_frame_id);
+ GetCorrespondingIoThreadClient(request);
if (!io_thread_client)
return nullptr;

Powered by Google App Engine
This is Rietveld 408576698