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

Side by Side Diff: content/child/service_worker/service_worker_provider_context.h

Issue 309503014: Make ServiceWorkerDispatcher reuse existing WebServiceWorkerImpls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct comment. Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 19 matching lines...) Expand all
30 // An instance of this class holds document-related information (e.g. 30 // An instance of this class holds document-related information (e.g.
31 // .current). Created and destructed on the main thread. 31 // .current). Created and destructed on the main thread.
32 // TODO(kinuko): To support navigator.serviceWorker in dedicated workers 32 // TODO(kinuko): To support navigator.serviceWorker in dedicated workers
33 // this needs to be RefCountedThreadSafe and .current info needs to be 33 // this needs to be RefCountedThreadSafe and .current info needs to be
34 // handled in a thread-safe manner (e.g. by a lock etc). 34 // handled in a thread-safe manner (e.g. by a lock etc).
35 class ServiceWorkerProviderContext 35 class ServiceWorkerProviderContext
36 : public base::RefCounted<ServiceWorkerProviderContext> { 36 : public base::RefCounted<ServiceWorkerProviderContext> {
37 public: 37 public:
38 explicit ServiceWorkerProviderContext(int provider_id); 38 explicit ServiceWorkerProviderContext(int provider_id);
39 39
40 // Returns a new handle reference for .current.
41 scoped_ptr<ServiceWorkerHandleReference> GetCurrentServiceWorkerHandle();
42
43 // Called from ServiceWorkerDispatcher. 40 // Called from ServiceWorkerDispatcher.
44 void OnServiceWorkerStateChanged(int handle_id, 41 void OnServiceWorkerStateChanged(int handle_id,
45 blink::WebServiceWorkerState state); 42 blink::WebServiceWorkerState state);
46 void OnSetCurrentServiceWorker(int provider_id, 43 void OnSetCurrentServiceWorker(int provider_id,
47 const ServiceWorkerObjectInfo& info); 44 const ServiceWorkerObjectInfo& info);
48 45
49 int provider_id() const { return provider_id_; } 46 int provider_id() const { return provider_id_; }
47
48 // Gets the context's handle reference for .controller.
49 // TODO(dominicc): Rename this to "controller".
50 ServiceWorkerHandleReference* current();
51
52 // Gets the handle ID of the controller, or
53 // kInvalidServiceWorkerHandleId if the provider is not controlled
54 // by a Service Worker.
50 int current_handle_id() const; 55 int current_handle_id() const;
51 56
52 private: 57 private:
53 friend class base::RefCounted<ServiceWorkerProviderContext>; 58 friend class base::RefCounted<ServiceWorkerProviderContext>;
54 ~ServiceWorkerProviderContext(); 59 ~ServiceWorkerProviderContext();
55 60
56 const int provider_id_; 61 const int provider_id_;
57 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_; 62 scoped_refptr<base::MessageLoopProxy> main_thread_loop_proxy_;
58 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 63 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
59 scoped_ptr<ServiceWorkerHandleReference> current_; 64 scoped_ptr<ServiceWorkerHandleReference> current_;
60 65
61 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext); 66 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderContext);
62 }; 67 };
63 68
64 } // namespace content 69 } // namespace content
65 70
66 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_ 71 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698