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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 2689693003: Add a helper method to create SW SimpleEventCallbacks. (Closed)
Patch Set: Add a helper method to create SW SimpleEventCallbacks. Created 3 years, 10 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 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_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/debug/crash_logging.h" 9 #include "base/debug/crash_logging.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 event->source = source; 1233 event->source = source;
1234 1234
1235 // Hide the client url if the client has a unique origin. 1235 // Hide the client url if the client has a unique origin.
1236 if (source_origin.unique()) { 1236 if (source_origin.unique()) {
1237 if (event->source.client_info.IsValid()) 1237 if (event->source.client_info.IsValid())
1238 event->source.client_info.url = GURL(); 1238 event->source.client_info.url = GURL();
1239 else 1239 else
1240 event->source.service_worker_info.url = GURL(); 1240 event->source.service_worker_info.url = GURL();
1241 } 1241 }
1242 1242
1243 // |event_dispatcher| is owned by |worker|, once |worker| got destroyed, the
1244 // bound function will never be called, so it is safe to use
1245 // base::Unretained() here.
1246 worker->event_dispatcher()->DispatchExtendableMessageEvent( 1243 worker->event_dispatcher()->DispatchExtendableMessageEvent(
1247 std::move(event), base::Bind(&ServiceWorkerVersion::OnSimpleEventFinished, 1244 std::move(event), worker->CreateSimpleEventCallback(request_id));
1248 base::Unretained(worker.get()), request_id));
1249 } 1245 }
1250 1246
1251 template <typename SourceInfo> 1247 template <typename SourceInfo>
1252 void ServiceWorkerDispatcherHost::DidFailToDispatchExtendableMessageEvent( 1248 void ServiceWorkerDispatcherHost::DidFailToDispatchExtendableMessageEvent(
1253 const std::vector<int>& sent_message_ports, 1249 const std::vector<int>& sent_message_ports,
1254 const SourceInfo& source_info, 1250 const SourceInfo& source_info,
1255 const StatusCallback& callback, 1251 const StatusCallback& callback,
1256 ServiceWorkerStatusCode status) { 1252 ServiceWorkerStatusCode status) {
1257 // Transfering the message ports failed, so destroy the ports. 1253 // Transfering the message ports failed, so destroy the ports.
1258 for (int port : sent_message_ports) 1254 for (int port : sent_message_ports)
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 if (!handle) { 1802 if (!handle) {
1807 bad_message::ReceivedBadMessage(this, 1803 bad_message::ReceivedBadMessage(this,
1808 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1804 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1809 return; 1805 return;
1810 } 1806 }
1811 handle->version()->StopWorker( 1807 handle->version()->StopWorker(
1812 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1808 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1813 } 1809 }
1814 1810
1815 } // namespace content 1811 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/push_messaging/push_messaging_router.cc ('k') | content/browser/service_worker/service_worker_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698