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

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

Issue 246023007: Chromium-side plumbing for ServiceWorker -> Document postMessage (2/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: message port threading fix Created 6 years, 7 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 | Annotate | Revision Log
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_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string16.h"
9 #include "content/browser/service_worker/embedded_worker_instance.h" 10 #include "content/browser/service_worker/embedded_worker_instance.h"
10 #include "content/browser/service_worker/embedded_worker_registry.h" 11 #include "content/browser/service_worker/embedded_worker_registry.h"
11 #include "content/browser/service_worker/service_worker_context_core.h" 12 #include "content/browser/service_worker/service_worker_context_core.h"
12 #include "content/browser/service_worker/service_worker_registration.h" 13 #include "content/browser/service_worker/service_worker_registration.h"
13 #include "content/common/service_worker/service_worker_messages.h" 14 #include "content/common/service_worker/service_worker_messages.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 17
17 namespace content { 18 namespace content {
18 19
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClientDocuments, 423 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClientDocuments,
423 OnGetClientDocuments) 424 OnGetClientDocuments)
424 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ActivateEventFinished, 425 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ActivateEventFinished,
425 OnActivateEventFinished) 426 OnActivateEventFinished)
426 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_InstallEventFinished, 427 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_InstallEventFinished,
427 OnInstallEventFinished) 428 OnInstallEventFinished)
428 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FetchEventFinished, 429 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FetchEventFinished,
429 OnFetchEventFinished) 430 OnFetchEventFinished)
430 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SyncEventFinished, 431 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SyncEventFinished,
431 OnSyncEventFinished) 432 OnSyncEventFinished)
433 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToDocument,
434 OnPostMessageToDocument)
432 IPC_MESSAGE_UNHANDLED(handled = false) 435 IPC_MESSAGE_UNHANDLED(handled = false)
433 IPC_END_MESSAGE_MAP() 436 IPC_END_MESSAGE_MAP()
434 return handled; 437 return handled;
435 } 438 }
436 439
437 void ServiceWorkerVersion::RunStartWorkerCallbacksOnError( 440 void ServiceWorkerVersion::RunStartWorkerCallbacksOnError(
438 ServiceWorkerStatusCode status) { 441 ServiceWorkerStatusCode status) {
439 if (status != SERVICE_WORKER_OK) 442 if (status != SERVICE_WORKER_OK)
440 RunCallbacks(this, &start_callbacks_, status); 443 RunCallbacks(this, &start_callbacks_, status);
441 } 444 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 script_cache_map_[url] = resource_id; 557 script_cache_map_[url] = resource_id;
555 } 558 }
556 559
557 int64 ServiceWorkerVersion::LookupInScriptCache(const GURL& url) { 560 int64 ServiceWorkerVersion::LookupInScriptCache(const GURL& url) {
558 ResourceIDMap::const_iterator found = script_cache_map_.find(url); 561 ResourceIDMap::const_iterator found = script_cache_map_.find(url);
559 if (found == script_cache_map_.end()) 562 if (found == script_cache_map_.end())
560 return kInvalidServiceWorkerResponseId; 563 return kInvalidServiceWorkerResponseId;
561 return found->second; 564 return found->second;
562 } 565 }
563 566
567 void ServiceWorkerVersion::OnPostMessageToDocument(
568 int client_id,
569 const base::string16& message,
570 const std::vector<int>& sent_message_port_ids) {
571 ServiceWorkerProviderHost* provider_host =
572 controllee_by_id_.Lookup(client_id);
573 if (!provider_host) {
574 // The client may already have been closed, just ignore.
575 return;
576 }
577 provider_host->PostMessage(message, sent_message_port_ids);
578 }
579
564 } // namespace content 580 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698