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

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

Issue 165373004: Move WorkerTaskRunner to content/child. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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/service_worker_dispatcher.h" 5 #include "content/child/service_worker/service_worker_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 #include "content/child/service_worker/web_service_worker_impl.h" 9 #include "content/child/service_worker/web_service_worker_impl.h"
10 #include "content/child/thread_safe_sender.h" 10 #include "content/child/thread_safe_sender.h"
11 #include "content/common/service_worker/service_worker_messages.h" 11 #include "content/common/service_worker/service_worker_messages.h"
12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
13 13
14 using blink::WebServiceWorkerError; 14 using blink::WebServiceWorkerError;
15 using blink::WebServiceWorkerProvider; 15 using blink::WebServiceWorkerProvider;
16 using base::ThreadLocalPointer; 16 using base::ThreadLocalPointer;
17 using webkit_glue::WorkerTaskRunner;
18 17
19 namespace content { 18 namespace content {
20 19
21 namespace { 20 namespace {
22 21
23 base::LazyInstance<ThreadLocalPointer<ServiceWorkerDispatcher> >::Leaky 22 base::LazyInstance<ThreadLocalPointer<ServiceWorkerDispatcher> >::Leaky
24 g_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; 23 g_dispatcher_tls = LAZY_INSTANCE_INITIALIZER;
25 24
26 ServiceWorkerDispatcher* const kHasBeenDeleted = 25 ServiceWorkerDispatcher* const kHasBeenDeleted =
27 reinterpret_cast<ServiceWorkerDispatcher*>(0x1); 26 reinterpret_cast<ServiceWorkerDispatcher*>(0x1);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { 82 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
84 NOTREACHED() << "Re-instantiating TLS ServiceWorkerDispatcher."; 83 NOTREACHED() << "Re-instantiating TLS ServiceWorkerDispatcher.";
85 g_dispatcher_tls.Pointer()->Set(NULL); 84 g_dispatcher_tls.Pointer()->Set(NULL);
86 } 85 }
87 if (g_dispatcher_tls.Pointer()->Get()) 86 if (g_dispatcher_tls.Pointer()->Get())
88 return g_dispatcher_tls.Pointer()->Get(); 87 return g_dispatcher_tls.Pointer()->Get();
89 88
90 ServiceWorkerDispatcher* dispatcher = 89 ServiceWorkerDispatcher* dispatcher =
91 new ServiceWorkerDispatcher(thread_safe_sender); 90 new ServiceWorkerDispatcher(thread_safe_sender);
92 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) 91 if (WorkerTaskRunner::Instance()->CurrentWorkerId())
93 webkit_glue::WorkerTaskRunner::Instance()->AddStopObserver(dispatcher); 92 WorkerTaskRunner::Instance()->AddStopObserver(dispatcher);
94 return dispatcher; 93 return dispatcher;
95 } 94 }
96 95
97 void ServiceWorkerDispatcher::OnRegistered(int32 thread_id, 96 void ServiceWorkerDispatcher::OnRegistered(int32 thread_id,
98 int32 request_id, 97 int32 request_id,
99 int64 registration_id) { 98 int64 registration_id) {
100 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks = 99 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks =
101 pending_callbacks_.Lookup(request_id); 100 pending_callbacks_.Lookup(request_id);
102 DCHECK(callbacks); 101 DCHECK(callbacks);
103 if (!callbacks) 102 if (!callbacks)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 140
142 scoped_ptr<WebServiceWorkerError> error( 141 scoped_ptr<WebServiceWorkerError> error(
143 new WebServiceWorkerError(error_type, message)); 142 new WebServiceWorkerError(error_type, message));
144 callbacks->onError(error.release()); 143 callbacks->onError(error.release());
145 pending_callbacks_.Remove(request_id); 144 pending_callbacks_.Remove(request_id);
146 } 145 }
147 146
148 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { delete this; } 147 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { delete this; }
149 148
150 } // namespace content 149 } // namespace content
OLDNEW
« no previous file with comments | « content/child/service_worker/service_worker_dispatcher.h ('k') | content/child/webkitplatformsupport_child_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698