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

Unified Diff: third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp

Issue 2807533003: [WIP2] off-main-thread loading
Patch Set: rebase Created 3 years, 7 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: third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp b/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp
index 9f21b6665a3165a2db2e9d5eefa2935a9790a0b4..5cba674025534963fdda16443e6db50129ec17cf 100644
--- a/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp
@@ -7,14 +7,17 @@
#include "core/frame/Deprecation.h"
#include "core/frame/UseCounter.h"
#include "core/loader/MixedContentChecker.h"
+#include "core/probe/CoreProbes.h"
#include "core/timing/WorkerGlobalScopePerformance.h"
#include "core/workers/WorkerClients.h"
#include "core/workers/WorkerGlobalScope.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/Supplementable.h"
#include "platform/WebTaskRunner.h"
#include "platform/exported/WrappedResourceRequest.h"
#include "platform/loader/fetch/ResourceFetcher.h"
#include "platform/scheduler/child/web_scheduler.h"
+#include "platform/weborigin/SecurityPolicy.h"
#include "public/platform/Platform.h"
#include "public/platform/WebMixedContent.h"
#include "public/platform/WebMixedContentContextType.h"
@@ -122,15 +125,18 @@ SecurityContext* WorkerFetchContext::GetParentSecurityContext() const {
bool WorkerFetchContext::ShouldBlockRequestByInspector(
const ResourceRequest& resource_request) const {
- // TODO(horo): Implement this.
- return false;
+ bool should_block_request = false;
+ probe::shouldBlockRequest(worker_global_scope_, resource_request,
+ &should_block_request);
+ return should_block_request;
}
void WorkerFetchContext::DispatchDidBlockRequest(
const ResourceRequest& resource_request,
const FetchInitiatorInfo& fetch_initiator_info,
ResourceRequestBlockedReason blocked_reason) const {
- // TODO(horo): Implement this.
+ probe::didBlockRequest(worker_global_scope_, resource_request, nullptr,
+ fetch_initiator_info, blocked_reason);
}
void WorkerFetchContext::ReportLocalLoadFailed(const KURL&) const {
@@ -174,6 +180,11 @@ bool WorkerFetchContext::IsControlledByServiceWorker() const {
void WorkerFetchContext::PrepareRequest(ResourceRequest& request,
RedirectType) {
+ String user_agent = worker_global_scope_->UserAgent();
+ probe::applyUserAgentOverride(worker_global_scope_, &user_agent);
+ DCHECK(!user_agent.IsNull());
+ request.SetHTTPUserAgent(AtomicString(user_agent));
+
request.OverrideLoadingIPCType(WebURLRequest::LoadingIPCType::kMojo);
WrappedResourceRequest webreq(request);
web_context_->WillSendRequest(webreq);
@@ -183,6 +194,12 @@ RefPtr<WebTaskRunner> WorkerFetchContext::LoadingTaskRunner() const {
return loading_task_runner_;
}
+int64_t WorkerFetchContext::ServiceWorkerID() const {
+ // TODO(horo): ServiceWorkerID() is used only for memory cache which is
+ // disabled in worker thread. So we should remove this method.
+ return web_context_->ServiceWorkerID();
+}
+
void WorkerFetchContext::AddAdditionalRequestHeaders(ResourceRequest& request,
FetchResourceType type) {
BaseFetchContext::AddAdditionalRequestHeaders(request, type);
@@ -195,6 +212,15 @@ void WorkerFetchContext::AddAdditionalRequestHeaders(ResourceRequest& request,
request.SetHTTPHeaderField("Save-Data", "on");
}
+void WorkerFetchContext::DispatchWillSendRequest(
+ unsigned long identifier,
+ ResourceRequest& request,
+ const ResourceResponse& redirect_response,
+ const FetchInitiatorInfo& initiator_info) {
+ probe::willSendRequest(worker_global_scope_, identifier, nullptr, request,
+ redirect_response, initiator_info);
+}
+
void WorkerFetchContext::DispatchDidReceiveResponse(
unsigned long identifier,
const ResourceResponse& response,
@@ -212,6 +238,38 @@ void WorkerFetchContext::DispatchDidReceiveResponse(
web_context_->DidDisplayContentWithCertificateErrors(response.Url());
}
}
+ probe::didReceiveResourceResponse(worker_global_scope_, identifier, nullptr,
+ response, resource);
+}
+
+void WorkerFetchContext::DispatchDidReceiveData(unsigned long identifier,
+ const char* data,
+ int data_length) {
+ probe::didReceiveData(worker_global_scope_, identifier, nullptr, data,
+ data_length);
+}
+
+void WorkerFetchContext::DispatchDidReceiveEncodedData(
+ unsigned long identifier,
+ int encoded_data_length) {
+ probe::didReceiveEncodedDataLength(worker_global_scope_, identifier,
+ encoded_data_length);
+}
+
+void WorkerFetchContext::DispatchDidFinishLoading(unsigned long identifier,
+ double finish_time,
+ int64_t encoded_data_length,
+ int64_t decoded_body_length) {
+ probe::didFinishLoading(worker_global_scope_, identifier, nullptr,
+ finish_time, encoded_data_length,
+ decoded_body_length);
+}
+
+void WorkerFetchContext::DispatchDidFail(unsigned long identifier,
+ const ResourceError& error,
+ int64_t encoded_data_length,
+ bool is_internal_request) {
+ probe::didFailLoading(worker_global_scope_, identifier, error);
}
void WorkerFetchContext::AddResourceTiming(const ResourceTimingInfo& info) {
@@ -239,6 +297,7 @@ void WorkerFetchContext::SetFirstPartyCookieAndRequestorOrigin(
// `isNull()` check. https://crbug.com/625969
if (out_request.RequestorOrigin()->IsUnique())
out_request.SetRequestorOrigin(GetSecurityOrigin());
+ // TODO: Sandboxed flag?
}
DEFINE_TRACE(WorkerFetchContext) {

Powered by Google App Engine
This is Rietveld 408576698