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/message_port_message_filter.h" | 8 #include "content/browser/message_port_message_filter.h" |
9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
10 #include "content/browser/service_worker/service_worker_context_request_handler.
h" | 10 #include "content/browser/service_worker/service_worker_context_request_handler.
h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // something is amiss. | 97 // something is amiss. |
98 return false; | 98 return false; |
99 } | 99 } |
100 | 100 |
101 running_hosted_version_ = live_version; | 101 running_hosted_version_ = live_version; |
102 return true; | 102 return true; |
103 } | 103 } |
104 | 104 |
105 scoped_ptr<ServiceWorkerRequestHandler> | 105 scoped_ptr<ServiceWorkerRequestHandler> |
106 ServiceWorkerProviderHost::CreateRequestHandler( | 106 ServiceWorkerProviderHost::CreateRequestHandler( |
107 ResourceType::Type resource_type) { | 107 ResourceType::Type resource_type, |
| 108 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context) { |
108 if (IsHostToRunningServiceWorker()) { | 109 if (IsHostToRunningServiceWorker()) { |
109 return scoped_ptr<ServiceWorkerRequestHandler>( | 110 return scoped_ptr<ServiceWorkerRequestHandler>( |
110 new ServiceWorkerContextRequestHandler( | 111 new ServiceWorkerContextRequestHandler( |
111 context_, AsWeakPtr(), resource_type)); | 112 context_, AsWeakPtr(), blob_storage_context, resource_type)); |
112 } | 113 } |
113 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || | 114 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || |
114 active_version()) { | 115 active_version()) { |
115 return scoped_ptr<ServiceWorkerRequestHandler>( | 116 return scoped_ptr<ServiceWorkerRequestHandler>( |
116 new ServiceWorkerControlleeRequestHandler( | 117 new ServiceWorkerControlleeRequestHandler( |
117 context_, AsWeakPtr(), resource_type)); | 118 context_, AsWeakPtr(), blob_storage_context, resource_type)); |
118 } | 119 } |
119 return scoped_ptr<ServiceWorkerRequestHandler>(); | 120 return scoped_ptr<ServiceWorkerRequestHandler>(); |
120 } | 121 } |
121 | 122 |
122 void ServiceWorkerProviderHost::PostMessage( | 123 void ServiceWorkerProviderHost::PostMessage( |
123 const base::string16& message, | 124 const base::string16& message, |
124 const std::vector<int>& sent_message_port_ids) { | 125 const std::vector<int>& sent_message_port_ids) { |
125 if (!dispatcher_host_) | 126 if (!dispatcher_host_) |
126 return; // Could be NULL in some tests. | 127 return; // Could be NULL in some tests. |
127 | 128 |
128 std::vector<int> new_routing_ids; | 129 std::vector<int> new_routing_ids; |
129 dispatcher_host_->message_port_message_filter()-> | 130 dispatcher_host_->message_port_message_filter()-> |
130 UpdateMessagePortsWithNewRoutes(sent_message_port_ids, | 131 UpdateMessagePortsWithNewRoutes(sent_message_port_ids, |
131 &new_routing_ids); | 132 &new_routing_ids); |
132 | 133 |
133 dispatcher_host_->Send( | 134 dispatcher_host_->Send( |
134 new ServiceWorkerMsg_MessageToDocument( | 135 new ServiceWorkerMsg_MessageToDocument( |
135 kDocumentMainThreadId, provider_id(), | 136 kDocumentMainThreadId, provider_id(), |
136 message, | 137 message, |
137 sent_message_port_ids, | 138 sent_message_port_ids, |
138 new_routing_ids)); | 139 new_routing_ids)); |
139 } | 140 } |
140 | 141 |
141 } // namespace content | 142 } // namespace content |
OLD | NEW |