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

Side by Side Diff: content/browser/service_worker/service_worker_provider_host.h

Issue 261533003: Populate .current when navigator.serviceWorker is accessed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 24 matching lines...) Expand all
35 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> { 35 : public base::SupportsWeakPtr<ServiceWorkerProviderHost> {
36 public: 36 public:
37 ServiceWorkerProviderHost(int process_id, 37 ServiceWorkerProviderHost(int process_id,
38 int provider_id, 38 int provider_id,
39 base::WeakPtr<ServiceWorkerContextCore> context, 39 base::WeakPtr<ServiceWorkerContextCore> context,
40 ServiceWorkerDispatcherHost* dispatcher_host); 40 ServiceWorkerDispatcherHost* dispatcher_host);
41 ~ServiceWorkerProviderHost(); 41 ~ServiceWorkerProviderHost();
42 42
43 int process_id() const { return process_id_; } 43 int process_id() const { return process_id_; }
44 int provider_id() const { return provider_id_; } 44 int provider_id() const { return provider_id_; }
45 const std::set<int>& script_client_thread_ids() const {
46 return script_client_thread_ids_;
47 }
48 45
49 bool IsHostToRunningServiceWorker() { 46 bool IsHostToRunningServiceWorker() {
50 return running_hosted_version_ != NULL; 47 return running_hosted_version_ != NULL;
51 } 48 }
52 49
53 // The service worker version that corresponds with 50 // The service worker version that corresponds with
54 // navigator.serviceWorker.active for our document. 51 // navigator.serviceWorker.active for our document.
55 ServiceWorkerVersion* active_version() const { 52 ServiceWorkerVersion* active_version() const {
56 return active_version_.get(); 53 return active_version_.get();
57 } 54 }
58 55
59 // The service worker version that corresponds with 56 // The service worker version that corresponds with
60 // navigate.serviceWorker.pending for our document. 57 // navigate.serviceWorker.pending for our document.
61 ServiceWorkerVersion* pending_version() const { 58 ServiceWorkerVersion* pending_version() const {
62 return pending_version_.get(); 59 return pending_version_.get();
63 } 60 }
64 61
65 // The running version, if any, that this provider is providing resource 62 // The running version, if any, that this provider is providing resource
66 // loads for. 63 // loads for.
67 ServiceWorkerVersion* running_hosted_version() const { 64 ServiceWorkerVersion* running_hosted_version() const {
68 return running_hosted_version_.get(); 65 return running_hosted_version_.get();
69 } 66 }
70 67
71 void set_document_url(const GURL& url) { document_url_ = url; } 68 void set_document_url(const GURL& url) { document_url_ = url; }
72 const GURL& document_url() const { return document_url_; } 69 const GURL& document_url() const { return document_url_; }
73 70
74 // Adds and removes script client thread ID, who is listening events
75 // dispatched from ServiceWorker to the document (and any of its dedicated
76 // workers) corresponding to this provider.
77 void AddScriptClient(int thread_id);
78 void RemoveScriptClient(int thread_id);
79
80 // Associate |version| to this provider as its '.active' or '.pending' 71 // Associate |version| to this provider as its '.active' or '.pending'
81 // version. 72 // version.
82 // Giving NULL to this method will unset the corresponding field. 73 // Giving NULL to this method will unset the corresponding field.
83 void SetActiveVersion(ServiceWorkerVersion* version); 74 void SetActiveVersion(ServiceWorkerVersion* version);
84 void SetPendingVersion(ServiceWorkerVersion* version); 75 void SetPendingVersion(ServiceWorkerVersion* version);
85 76
86 // Returns false if the version is not in the expected STARTING in our 77 // Returns false if the version is not in the expected STARTING in our
87 // our process state. That would be indicative of a bad IPC message. 78 // our process state. That would be indicative of a bad IPC message.
88 bool SetHostedVersionId(int64 versions_id); 79 bool SetHostedVersionId(int64 versions_id);
89 80
90 // Returns a handler for a request, the handler may return NULL if 81 // Returns a handler for a request, the handler may return NULL if
91 // the request doesn't require special handling. 82 // the request doesn't require special handling.
92 scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler( 83 scoped_ptr<ServiceWorkerRequestHandler> CreateRequestHandler(
93 ResourceType::Type resource_type); 84 ResourceType::Type resource_type);
94 85
95 private: 86 private:
96 const int process_id_; 87 const int process_id_;
97 const int provider_id_; 88 const int provider_id_;
98 GURL document_url_; 89 GURL document_url_;
99 std::set<int> script_client_thread_ids_;
100 scoped_refptr<ServiceWorkerVersion> active_version_; 90 scoped_refptr<ServiceWorkerVersion> active_version_;
101 scoped_refptr<ServiceWorkerVersion> pending_version_; 91 scoped_refptr<ServiceWorkerVersion> pending_version_;
102 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; 92 scoped_refptr<ServiceWorkerVersion> running_hosted_version_;
103 base::WeakPtr<ServiceWorkerContextCore> context_; 93 base::WeakPtr<ServiceWorkerContextCore> context_;
104 ServiceWorkerDispatcherHost* dispatcher_host_; 94 ServiceWorkerDispatcherHost* dispatcher_host_;
105 95
106 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); 96 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost);
107 }; 97 };
108 98
109 } // namespace content 99 } // namespace content
110 100
111 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ 101 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698