| 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_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 
| 6 | 6 | 
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" | 
|  | 8 #include "content/browser/service_worker/embedded_worker_registry.h" | 
| 8 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" | 
| 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 
| 10 #include "content/browser/service_worker/service_worker_provider_host.h" | 11 #include "content/browser/service_worker/service_worker_provider_host.h" | 
| 11 #include "content/common/service_worker_messages.h" | 12 #include "content/common/service_worker_messages.h" | 
| 12 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" | 
| 13 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" | 14 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" | 
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" | 
| 15 | 16 | 
| 16 namespace content { | 17 namespace content { | 
| 17 | 18 | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 30 } | 31 } | 
| 31 | 32 | 
| 32 }  // namespace | 33 }  // namespace | 
| 33 | 34 | 
| 34 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( | 35 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( | 
| 35     int render_process_id) | 36     int render_process_id) | 
| 36     : render_process_id_(render_process_id) { | 37     : render_process_id_(render_process_id) { | 
| 37 } | 38 } | 
| 38 | 39 | 
| 39 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { | 40 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { | 
| 40   if (context_) | 41   if (context_) { | 
| 41     context_->RemoveAllProviderHostsForProcess(render_process_id_); | 42     context_->RemoveAllProviderHostsForProcess(render_process_id_); | 
|  | 43     context_->embedded_worker_registry()->RemoveChildProcessSender( | 
|  | 44         render_process_id_); | 
|  | 45   } | 
| 42 } | 46 } | 
| 43 | 47 | 
| 44 void ServiceWorkerDispatcherHost::Init( | 48 void ServiceWorkerDispatcherHost::Init( | 
| 45     ServiceWorkerContextWrapper* context_wrapper) { | 49     ServiceWorkerContextWrapper* context_wrapper) { | 
| 46   if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 50   if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 
| 47     BrowserThread::PostTask( | 51     BrowserThread::PostTask( | 
| 48         BrowserThread::IO, FROM_HERE, | 52         BrowserThread::IO, FROM_HERE, | 
| 49         base::Bind(&ServiceWorkerDispatcherHost::Init, | 53         base::Bind(&ServiceWorkerDispatcherHost::Init, | 
| 50                     this, make_scoped_refptr(context_wrapper))); | 54                     this, make_scoped_refptr(context_wrapper))); | 
| 51       return; | 55       return; | 
| 52   } | 56   } | 
| 53   context_ = context_wrapper->context()->AsWeakPtr(); | 57   context_ = context_wrapper->context()->AsWeakPtr(); | 
|  | 58   context_->embedded_worker_registry()->AddChildProcessSender( | 
|  | 59       render_process_id_, this); | 
| 54 } | 60 } | 
| 55 | 61 | 
| 56 void ServiceWorkerDispatcherHost::OnDestruct() const { | 62 void ServiceWorkerDispatcherHost::OnDestruct() const { | 
| 57   BrowserThread::DeleteOnIOThread::Destruct(this); | 63   BrowserThread::DeleteOnIOThread::Destruct(this); | 
| 58 } | 64 } | 
| 59 | 65 | 
| 60 bool ServiceWorkerDispatcherHost::OnMessageReceived( | 66 bool ServiceWorkerDispatcherHost::OnMessageReceived( | 
| 61     const IPC::Message& message, | 67     const IPC::Message& message, | 
| 62     bool* message_was_ok) { | 68     bool* message_was_ok) { | 
| 63   if (IPC_MESSAGE_CLASS(message) != ServiceWorkerMsgStart) | 69   if (IPC_MESSAGE_CLASS(message) != ServiceWorkerMsgStart) | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 145   if (!context_) | 151   if (!context_) | 
| 146     return; | 152     return; | 
| 147   if (!context_->GetProviderHost(render_process_id_, provider_id)) { | 153   if (!context_->GetProviderHost(render_process_id_, provider_id)) { | 
| 148     BadMessageReceived(); | 154     BadMessageReceived(); | 
| 149     return; | 155     return; | 
| 150   } | 156   } | 
| 151   context_->RemoveProviderHost(render_process_id_, provider_id); | 157   context_->RemoveProviderHost(render_process_id_, provider_id); | 
| 152 } | 158 } | 
| 153 | 159 | 
| 154 }  // namespace content | 160 }  // namespace content | 
| OLD | NEW | 
|---|