OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/service_worker/service_worker_provider_host.h" | 5 #include "content/browser/service_worker/service_worker_provider_host.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/browser/service_worker/service_worker_context_core.h" | 8 #include "content/browser/service_worker/service_worker_context_core.h" |
9 #include "content/browser/service_worker/service_worker_context_request_handler. h" | |
10 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h" | |
9 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 11 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
10 #include "content/browser/service_worker/service_worker_handle.h" | 12 #include "content/browser/service_worker/service_worker_handle.h" |
11 #include "content/browser/service_worker/service_worker_utils.h" | 13 #include "content/browser/service_worker/service_worker_utils.h" |
12 #include "content/browser/service_worker/service_worker_version.h" | 14 #include "content/browser/service_worker/service_worker_version.h" |
13 #include "content/common/service_worker/service_worker_messages.h" | 15 #include "content/common/service_worker/service_worker_messages.h" |
14 | 16 |
15 namespace content { | 17 namespace content { |
16 | 18 |
17 ServiceWorkerProviderHost::ServiceWorkerProviderHost( | 19 ServiceWorkerProviderHost::ServiceWorkerProviderHost( |
18 int process_id, int provider_id, | 20 int process_id, int provider_id, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 info.process_id != process_id_) { | 108 info.process_id != process_id_) { |
107 // If we aren't trying to start this version in our process | 109 // If we aren't trying to start this version in our process |
108 // something is amiss. | 110 // something is amiss. |
109 return false; | 111 return false; |
110 } | 112 } |
111 | 113 |
112 hosted_version_ = live_version; | 114 hosted_version_ = live_version; |
113 return true; | 115 return true; |
114 } | 116 } |
115 | 117 |
116 bool ServiceWorkerProviderHost::ShouldHandleRequest( | 118 scoped_ptr<ServiceWorkerRequestHandler> |
117 ResourceType::Type resource_type) const { | 119 ServiceWorkerProviderHost::CreateRequestHandler( |
118 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) | 120 ResourceType::Type resource_type) { |
119 return true; | 121 if (hosted_version_) { |
jsbell
2014/04/24 21:22:24
Whoah, just cluing into the fact that ServiceWorke
michaeln
2014/04/24 21:49:17
Good idea, I'll do both in this CL.
michaeln
2014/04/24 21:59:18
Having a bit of a hard time with terminology, hows
| |
120 | 122 return scoped_ptr<ServiceWorkerRequestHandler>( |
121 if (active_version()) | 123 new ServiceWorkerContextRequestHandler( |
122 return true; | 124 context_, AsWeakPtr(), resource_type)); |
123 | 125 } |
124 // TODO(kinuko): Handle ServiceWorker cases. | 126 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || |
125 // For now we always return false here, so that we don't handle | 127 active_version()) { |
126 // requests for ServiceWorker (either for the main or sub resources). | 128 return scoped_ptr<ServiceWorkerRequestHandler>( |
127 | 129 new ServiceWorkerControlleeRequestHandler( |
128 return false; | 130 context_, AsWeakPtr(), resource_type)); |
131 } | |
132 return scoped_ptr<ServiceWorkerRequestHandler>(); | |
129 } | 133 } |
130 | 134 |
131 } // namespace content | 135 } // namespace content |
OLD | NEW |