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

Side by Side Diff: content/browser/navigator_connect/navigator_connect_service_worker_service_factory.cc

Issue 1079923002: ServiceWorker: Stop exposing ServiceWorkerContextCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/navigator_connect/navigator_connect_service_worker_ser vice_factory.h" 5 #include "content/browser/navigator_connect/navigator_connect_service_worker_ser vice_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/message_port_service.h" 8 #include "content/browser/message_port_service.h"
9 #include "content/browser/service_worker/service_worker_context_wrapper.h" 9 #include "content/browser/service_worker/service_worker_context_wrapper.h"
10 #include "content/browser/service_worker/service_worker_utils.h" 10 #include "content/browser/service_worker/service_worker_utils.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 DCHECK(route_id == client_.message_port_id); 76 DCHECK(route_id == client_.message_port_id);
77 DCHECK(message.message_as_value.empty()); 77 DCHECK(message.message_as_value.empty());
78 78
79 // Hold messages on transferred message ports. Actual delivery of the message 79 // Hold messages on transferred message ports. Actual delivery of the message
80 // by the service can be asynchronous. When a message is delivered, 80 // by the service can be asynchronous. When a message is delivered,
81 // WebMessagePortChannelImpl instances will be constructed which send 81 // WebMessagePortChannelImpl instances will be constructed which send
82 // MessagePortHostMsg_ReleaseMessages to release messages. 82 // MessagePortHostMsg_ReleaseMessages to release messages.
83 for (const auto& port : sent_message_ports) 83 for (const auto& port : sent_message_ports)
84 MessagePortService::GetInstance()->HoldMessages(port.id); 84 MessagePortService::GetInstance()->HoldMessages(port.id);
85 85
86 service_worker_context_->context()->storage()->FindRegistrationForId( 86 service_worker_context_->FindRegistrationForId(
87 service_worker_registration_id_, service_worker_registration_origin_, 87 service_worker_registration_id_, service_worker_registration_origin_,
88 base::Bind(&NavigatorConnectServiceWorkerService::DeliverMessage, 88 base::Bind(&NavigatorConnectServiceWorkerService::DeliverMessage,
89 weak_factory_.GetWeakPtr(), message.message_as_string, 89 weak_factory_.GetWeakPtr(), message.message_as_string,
90 sent_message_ports)); 90 sent_message_ports));
91 } 91 }
92 92
93 void NavigatorConnectServiceWorkerService::SendMessagesAreQueued(int route_id) { 93 void NavigatorConnectServiceWorkerService::SendMessagesAreQueued(int route_id) {
94 NOTREACHED() << "navigator.connect endpoints should never queue messages."; 94 NOTREACHED() << "navigator.connect endpoints should never queue messages.";
95 } 95 }
96 96
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // if no other factory claims to handle the url. 136 // if no other factory claims to handle the url.
137 return true; 137 return true;
138 } 138 }
139 139
140 void NavigatorConnectServiceWorkerServiceFactory::Connect( 140 void NavigatorConnectServiceWorkerServiceFactory::Connect(
141 const NavigatorConnectClient& client, 141 const NavigatorConnectClient& client,
142 const ConnectCallback& callback) { 142 const ConnectCallback& callback) {
143 DCHECK_CURRENTLY_ON(BrowserThread::IO); 143 DCHECK_CURRENTLY_ON(BrowserThread::IO);
144 144
145 // Find the right service worker to service this connection. 145 // Find the right service worker to service this connection.
146 service_worker_context_->context()->storage()->FindRegistrationForDocument( 146 service_worker_context_->FindRegistrationForDocument(
147 client.target_url, 147 client.target_url,
148 base::Bind(&NavigatorConnectServiceWorkerServiceFactory:: 148 base::Bind(&NavigatorConnectServiceWorkerServiceFactory::
149 GotServiceWorkerRegistration, 149 GotServiceWorkerRegistration,
150 weak_factory_.GetWeakPtr(), callback, client)); 150 weak_factory_.GetWeakPtr(), callback, client));
151 } 151 }
152 152
153 void NavigatorConnectServiceWorkerServiceFactory::GotServiceWorkerRegistration( 153 void NavigatorConnectServiceWorkerServiceFactory::GotServiceWorkerRegistration(
154 const ConnectCallback& callback, 154 const ConnectCallback& callback,
155 const NavigatorConnectClient& client, 155 const NavigatorConnectClient& client,
156 ServiceWorkerStatusCode status, 156 ServiceWorkerStatusCode status,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // TODO(mek): http://crbug.com/462744 Keep track of these 192 // TODO(mek): http://crbug.com/462744 Keep track of these
193 // NavigatorConnectServiceWorkerService instances and clean them up when a 193 // NavigatorConnectServiceWorkerService instances and clean them up when a
194 // service worker registration is deleted. 194 // service worker registration is deleted.
195 callback.Run( 195 callback.Run(
196 new NavigatorConnectServiceWorkerService(service_worker_context_, client, 196 new NavigatorConnectServiceWorkerService(service_worker_context_, client,
197 service_worker_registration), 197 service_worker_registration),
198 false); 198 false);
199 } 199 }
200 200
201 } // namespace content 201 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/geofencing/geofencing_manager.cc ('k') | content/browser/notifications/notification_event_dispatcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698