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

Side by Side Diff: content/child/service_worker/web_service_worker_provider_impl.cc

Issue 477593007: ServiceWorker: Make '.ready' return a promise to be resolved with ServiceWorkerRegistration (2/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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/child/service_worker/web_service_worker_provider_impl.h" 5 #include "content/child/service_worker/web_service_worker_provider_impl.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/child/child_thread.h" 9 #include "content/child/child_thread.h"
10 #include "content/child/service_worker/service_worker_dispatcher.h" 10 #include "content/child/service_worker/service_worker_dispatcher.h"
11 #include "content/child/service_worker/service_worker_handle_reference.h" 11 #include "content/child/service_worker/service_worker_handle_reference.h"
12 #include "content/child/service_worker/service_worker_provider_context.h" 12 #include "content/child/service_worker/service_worker_provider_context.h"
13 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h"
13 #include "content/child/service_worker/web_service_worker_impl.h" 14 #include "content/child/service_worker/web_service_worker_impl.h"
15 #include "content/child/service_worker/web_service_worker_registration_impl.h"
14 #include "content/child/thread_safe_sender.h" 16 #include "content/child/thread_safe_sender.h"
15 #include "content/common/service_worker/service_worker_messages.h" 17 #include "content/common/service_worker/service_worker_messages.h"
16 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h" 18 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h"
17 #include "third_party/WebKit/public/platform/WebURL.h" 19 #include "third_party/WebKit/public/platform/WebURL.h"
18 20
19 using blink::WebURL; 21 using blink::WebURL;
20 22
21 namespace content { 23 namespace content {
22 24
23 WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl( 25 WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl(
(...skipping 16 matching lines...) Expand all
40 return; 42 return;
41 } 43 }
42 44
43 // TODO(kinuko): Here we could also register the current thread ID 45 // TODO(kinuko): Here we could also register the current thread ID
44 // on the provider context so that multiple WebServiceWorkerProviderImpl 46 // on the provider context so that multiple WebServiceWorkerProviderImpl
45 // (e.g. on document and on dedicated workers) can properly share 47 // (e.g. on document and on dedicated workers) can properly share
46 // the single provider context across threads. (http://crbug.com/366538 48 // the single provider context across threads. (http://crbug.com/366538
47 // for more context) 49 // for more context)
48 GetDispatcher()->AddScriptClient(provider_id_, client); 50 GetDispatcher()->AddScriptClient(provider_id_, client);
49 51
50 if (context_->installing_handle_id() != kInvalidServiceWorkerHandleId) { 52 if (context_->active_handle_id() != kInvalidServiceWorkerHandleId) {
51 client->setInstalling(GetDispatcher()->GetServiceWorker( 53 WebServiceWorkerRegistrationImpl* registration =
52 context_->installing()->info(), false)); 54 GetDispatcher()->GetServiceWorkerRegistration(
53 } 55 context_->registration()->info(), false);
michaeln 2014/09/04 00:27:23 I know this is because things are in an intermedia
nhiroki 2014/09/08 15:55:52 Straightened the logic in the latest patchset. How
54 56
55 if (context_->waiting_handle_id() != kInvalidServiceWorkerHandleId) { 57 if (context_->installing_handle_id() != kInvalidServiceWorkerHandleId) {
56 client->setWaiting(GetDispatcher()->GetServiceWorker( 58 registration->SetInstalling(GetDispatcher()->GetServiceWorker(
michaeln 2014/09/04 00:27:23 Registration may be a preexising object accoding t
nhiroki 2014/09/08 15:55:52 Updated. The latest patchset just reuses the exist
57 context_->waiting()->info(), false)); 59 context_->installing()->info(), false));
58 } 60 }
61 if (context_->waiting_handle_id() != kInvalidServiceWorkerHandleId) {
62 registration->SetWaiting(GetDispatcher()->GetServiceWorker(
63 context_->waiting()->info(), false));
64 }
65 registration->SetActive(GetDispatcher()->GetServiceWorker(
66 context_->active()->info(), false));
59 67
60 if (context_->active_handle_id() != kInvalidServiceWorkerHandleId) { 68 client->setReady(GetDispatcher()->GetServiceWorkerRegistration(
61 client->setActive(GetDispatcher()->GetServiceWorker( 69 context_->registration()->info(), false));
michaeln 2014/09/04 00:27:23 Is there a reason to call GetServiceWorkerRegistra
nhiroki 2014/09/08 15:55:52 Oops... that's just my mistake. The local variable
62 context_->active()->info(), false));
63 } 70 }
64 71
65 if (context_->controller_handle_id() != kInvalidServiceWorkerHandleId) { 72 if (context_->controller_handle_id() != kInvalidServiceWorkerHandleId) {
66 client->setController(GetDispatcher()->GetServiceWorker( 73 client->setController(GetDispatcher()->GetServiceWorker(
67 context_->controller()->info(), false)); 74 context_->controller()->info(), false));
68 } 75 }
69 } 76 }
70 77
71 void WebServiceWorkerProviderImpl::registerServiceWorker( 78 void WebServiceWorkerProviderImpl::registerServiceWorker(
72 const WebURL& pattern, 79 const WebURL& pattern,
(...skipping 18 matching lines...) Expand all
91 if (dispatcher) 98 if (dispatcher)
92 dispatcher->RemoveScriptClient(provider_id_); 99 dispatcher->RemoveScriptClient(provider_id_);
93 } 100 }
94 101
95 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { 102 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() {
96 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( 103 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
97 thread_safe_sender_.get()); 104 thread_safe_sender_.get());
98 } 105 }
99 106
100 } // namespace content 107 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698