Chromium Code Reviews| Index: content/browser/service_worker/service_worker_controllee_request_handler.cc |
| diff --git a/content/browser/service_worker/service_worker_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc |
| similarity index 54% |
| copy from content/browser/service_worker/service_worker_request_handler.cc |
| copy to content/browser/service_worker/service_worker_controllee_request_handler.cc |
| index 2e3c5c4623350cef1e8ead5bc3a06fc3afdd739b..736092bf814c5d409992879f6d7b240e7d7de050 100644 |
| --- a/content/browser/service_worker/service_worker_request_handler.cc |
| +++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc |
| @@ -2,10 +2,9 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "content/browser/service_worker/service_worker_request_handler.h" |
| +#include "content/browser/service_worker/service_worker_controllee_request_handler.h" |
| #include "content/browser/service_worker/service_worker_context_core.h" |
| -#include "content/browser/service_worker/service_worker_context_wrapper.h" |
| #include "content/browser/service_worker/service_worker_provider_host.h" |
| #include "content/browser/service_worker/service_worker_registration.h" |
| #include "content/browser/service_worker/service_worker_url_request_job.h" |
| @@ -15,76 +14,19 @@ |
| namespace content { |
| -namespace { |
| - |
| -int kUserDataKey; // Key value is not important. |
| - |
| -class ServiceWorkerRequestInterceptor |
| - : public net::URLRequestJobFactory::ProtocolHandler { |
| - public: |
| - ServiceWorkerRequestInterceptor() {} |
| - virtual ~ServiceWorkerRequestInterceptor() {} |
| - virtual net::URLRequestJob* MaybeCreateJob( |
| - net::URLRequest* request, |
| - net::NetworkDelegate* network_delegate) const OVERRIDE { |
| - ServiceWorkerRequestHandler* handler = |
| - ServiceWorkerRequestHandler::GetHandler(request); |
| - if (!handler) |
| - return NULL; |
| - return handler->MaybeCreateJob(request, network_delegate); |
| - } |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestInterceptor); |
| -}; |
| - |
| -} // namespace |
| - |
| -void ServiceWorkerRequestHandler::InitializeHandler( |
| - net::URLRequest* request, |
| - ServiceWorkerContextWrapper* context_wrapper, |
| - int process_id, |
| - int provider_id, |
| - ResourceType::Type resource_type) { |
| - if (!ServiceWorkerUtils::IsFeatureEnabled()) |
| - return; |
| - |
| - if (!context_wrapper || !context_wrapper->context() || |
| - provider_id == kInvalidServiceWorkerProviderId) { |
| - return; |
| - } |
| - |
| - ServiceWorkerProviderHost* provider_host = |
| - context_wrapper->context()->GetProviderHost(process_id, provider_id); |
| - if (!provider_host) |
| - return; |
| - |
| - if (!provider_host->ShouldHandleRequest(resource_type)) |
| - return; |
| - |
| - scoped_ptr<ServiceWorkerRequestHandler> handler( |
| - new ServiceWorkerRequestHandler(context_wrapper->context()->AsWeakPtr(), |
| - provider_host->AsWeakPtr(), |
| - resource_type)); |
| - request->SetUserData(&kUserDataKey, handler.release()); |
| -} |
| - |
| -ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( |
| - net::URLRequest* request) { |
| - return reinterpret_cast<ServiceWorkerRequestHandler*>( |
| - request->GetUserData(&kUserDataKey)); |
| -} |
| - |
| -scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| -ServiceWorkerRequestHandler::CreateInterceptor() { |
| - return make_scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| - new ServiceWorkerRequestInterceptor); |
| +ServiceWorkerControlleeRequestHandler::ServiceWorkerControlleeRequestHandler( |
| + base::WeakPtr<ServiceWorkerContextCore> context, |
| + base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| + ResourceType::Type resource_type) |
| + : ServiceWorkerRequestHandler(context, provider_host, resource_type), |
| + weak_factory_(this) { |
| } |
| -ServiceWorkerRequestHandler::~ServiceWorkerRequestHandler() { |
| +ServiceWorkerControlleeRequestHandler:: |
| + ~ServiceWorkerControlleeRequestHandler() { |
| } |
| -net::URLRequestJob* ServiceWorkerRequestHandler::MaybeCreateJob( |
| +net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob( |
| net::URLRequest* request, |
| net::NetworkDelegate* network_delegate) { |
| if (!context_ || !provider_host_) { |
| @@ -128,17 +70,8 @@ net::URLRequestJob* ServiceWorkerRequestHandler::MaybeCreateJob( |
| return job_.get(); |
| } |
| -ServiceWorkerRequestHandler::ServiceWorkerRequestHandler( |
| - base::WeakPtr<ServiceWorkerContextCore> context, |
| - base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| - ResourceType::Type resource_type) |
| - : context_(context), |
| - provider_host_(provider_host), |
| - resource_type_(resource_type), |
| - weak_factory_(this) { |
| -} |
| - |
| -void ServiceWorkerRequestHandler::PrepareForMainResource(const GURL& url) { |
| +void ServiceWorkerControlleeRequestHandler:: |
| + PrepareForMainResource(const GURL& url) { |
|
kinuko
2014/04/24 05:15:00
Ah... are these indents made by git cl format I gu
michaeln
2014/04/24 19:01:19
i did that by hand, the class name is sooooo long
jsbell
2014/04/24 21:22:24
I'd just let `git-cl format` do it's thing. It bre
michaeln
2014/04/24 21:49:17
Done, taking git-cl format's suggestions across th
|
| DCHECK(job_.get()); |
| DCHECK(context_); |
| // The corresponding provider_host may already have associate version in |
| @@ -152,9 +85,10 @@ void ServiceWorkerRequestHandler::PrepareForMainResource(const GURL& url) { |
| weak_factory_.GetWeakPtr())); |
| } |
| -void ServiceWorkerRequestHandler::DidLookupRegistrationForMainResource( |
| - ServiceWorkerStatusCode status, |
| - const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| +void ServiceWorkerControlleeRequestHandler:: |
| + DidLookupRegistrationForMainResource( |
| + ServiceWorkerStatusCode status, |
| + const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| DCHECK(job_.get()); |
| if (status != SERVICE_WORKER_OK || !registration->active_version()) { |
| // No registration, or no active version for the registration is available. |
| @@ -167,7 +101,7 @@ void ServiceWorkerRequestHandler::DidLookupRegistrationForMainResource( |
| job_->ForwardToServiceWorker(); |
| } |
| -void ServiceWorkerRequestHandler::PrepareForSubResource() { |
| +void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { |
| DCHECK(job_.get()); |
| DCHECK(context_); |
| DCHECK(provider_host_->active_version()); |