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

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

Issue 2958753003: Revert "Create ServiceWorkerProviderHost before starting worker" (Closed)
Patch Set: Created 3 years, 5 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
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_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 26 matching lines...) Expand all
37 class ServiceWorkerProviderHost; 37 class ServiceWorkerProviderHost;
38 class ServiceWorkerRegistration; 38 class ServiceWorkerRegistration;
39 class ServiceWorkerRegistrationHandle; 39 class ServiceWorkerRegistrationHandle;
40 class ServiceWorkerVersion; 40 class ServiceWorkerVersion;
41 struct ServiceWorkerObjectInfo; 41 struct ServiceWorkerObjectInfo;
42 struct ServiceWorkerRegistrationObjectInfo; 42 struct ServiceWorkerRegistrationObjectInfo;
43 struct ServiceWorkerVersionAttributes; 43 struct ServiceWorkerVersionAttributes;
44 44
45 // This class is bound with mojom::ServiceWorkerDispatcherHost. All 45 // This class is bound with mojom::ServiceWorkerDispatcherHost. All
46 // InterfacePtrs on the same render process are bound to the same 46 // InterfacePtrs on the same render process are bound to the same
47 // content::ServiceWorkerDispatcherHost. This can be overridden only for 47 // content::ServiceWorkerDispatcherHost.
48 // testing.
49 class CONTENT_EXPORT ServiceWorkerDispatcherHost 48 class CONTENT_EXPORT ServiceWorkerDispatcherHost
50 : public BrowserMessageFilter, 49 : public BrowserMessageFilter,
51 public BrowserAssociatedInterface<mojom::ServiceWorkerDispatcherHost>, 50 public BrowserAssociatedInterface<mojom::ServiceWorkerDispatcherHost>,
52 public mojom::ServiceWorkerDispatcherHost { 51 public mojom::ServiceWorkerDispatcherHost {
53 public: 52 public:
54 ServiceWorkerDispatcherHost( 53 ServiceWorkerDispatcherHost(
55 int render_process_id, 54 int render_process_id,
56 ResourceContext* resource_context); 55 ResourceContext* resource_context);
57 56
58 void Init(ServiceWorkerContextWrapper* context_wrapper); 57 void Init(ServiceWorkerContextWrapper* context_wrapper);
59 58
60 // BrowserMessageFilter implementation 59 // BrowserMessageFilter implementation
61 void OnFilterAdded(IPC::Channel* channel) override; 60 void OnFilterAdded(IPC::Channel* channel) override;
62 void OnFilterRemoved() override; 61 void OnFilterRemoved() override;
63 void OnDestruct() const override; 62 void OnDestruct() const override;
64 bool OnMessageReceived(const IPC::Message& message) override; 63 bool OnMessageReceived(const IPC::Message& message) override;
65 64
66 // IPC::Sender implementation 65 // IPC::Sender implementation
67 66
68 // Send() queues the message until the underlying sender is ready. This 67 // Send() queues the message until the underlying sender is ready. This
69 // class assumes that Send() can only fail after that when the renderer 68 // class assumes that Send() can only fail after that when the renderer
70 // process has terminated, at which point the whole instance will eventually 69 // process has terminated, at which point the whole instance will eventually
71 // be destroyed. 70 // be destroyed.
72 bool Send(IPC::Message* message) override; 71 bool Send(IPC::Message* message) override;
73 72
74 // Virtual for testing. 73 void RegisterServiceWorkerHandle(std::unique_ptr<ServiceWorkerHandle> handle);
75 virtual void RegisterServiceWorkerHandle( 74 void RegisterServiceWorkerRegistrationHandle(
76 std::unique_ptr<ServiceWorkerHandle> handle);
77 // Virtual for testing.
78 virtual void RegisterServiceWorkerRegistrationHandle(
79 std::unique_ptr<ServiceWorkerRegistrationHandle> handle); 75 std::unique_ptr<ServiceWorkerRegistrationHandle> handle);
80 76
81 ServiceWorkerHandle* FindServiceWorkerHandle(int provider_id, 77 ServiceWorkerHandle* FindServiceWorkerHandle(int provider_id,
82 int64_t version_id); 78 int64_t version_id);
83 79
84 // Gets or creates the registration and version handles appropriate for
85 // representing |registration| inside of |provider_host|. Sets |out_info| and
86 // |out_attrs| accordingly for these handles.
87 void GetRegistrationObjectInfoAndVersionAttributes(
88 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
89 ServiceWorkerRegistration* registration,
90 ServiceWorkerRegistrationObjectInfo* out_info,
91 ServiceWorkerVersionAttributes* out_attrs);
92
93 // Returns the existing registration handle whose reference count is 80 // Returns the existing registration handle whose reference count is
94 // incremented or a newly created one if it doesn't exist. 81 // incremented or a newly created one if it doesn't exist.
95 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle( 82 ServiceWorkerRegistrationHandle* GetOrCreateRegistrationHandle(
96 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 83 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
97 ServiceWorkerRegistration* registration); 84 ServiceWorkerRegistration* registration);
98 85
99 protected: 86 protected:
100 ~ServiceWorkerDispatcherHost() override; 87 ~ServiceWorkerDispatcherHost() override;
101 88
102 private: 89 private:
103 friend class BrowserThread; 90 friend class BrowserThread;
104 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>; 91 friend class base::DeleteHelper<ServiceWorkerDispatcherHost>;
105 friend class ServiceWorkerDispatcherHostTest; 92 friend class ServiceWorkerDispatcherHostTest;
106 friend class TestingServiceWorkerDispatcherHost; 93 friend class TestingServiceWorkerDispatcherHost;
107 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDispatcherHostTest, 94 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDispatcherHostTest,
108 ProviderCreatedAndDestroyed); 95 ProviderCreatedAndDestroyed);
109 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDispatcherHostTest, 96 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerDispatcherHostTest,
110 CleanupOnRendererCrash); 97 CleanupOnRendererCrash);
111 FRIEND_TEST_ALL_PREFIXES(BackgroundSyncManagerTest,
112 RegisterWithoutLiveSWRegistration);
113 98
114 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>; 99 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode status)>;
115 enum class ProviderStatus { OK, NO_CONTEXT, DEAD_HOST, NO_HOST, NO_URL }; 100 enum class ProviderStatus { OK, NO_CONTEXT, DEAD_HOST, NO_HOST, NO_URL };
116 101
117 // mojom::ServiceWorkerDispatcherHost implementation 102 // mojom::ServiceWorkerDispatcherHost implementation
118 void OnProviderCreated(ServiceWorkerProviderHostInfo info) override; 103 void OnProviderCreated(ServiceWorkerProviderHostInfo info) override;
104 void OnSetHostedVersionId(int provider_id,
105 int64_t version_id,
106 int embedded_worker_id) override;
119 107
120 // IPC Message handlers 108 // IPC Message handlers
121 void OnRegisterServiceWorker(int thread_id, 109 void OnRegisterServiceWorker(int thread_id,
122 int request_id, 110 int request_id,
123 int provider_id, 111 int provider_id,
124 const GURL& pattern, 112 const GURL& pattern,
125 const GURL& script_url); 113 const GURL& script_url);
126 void OnUpdateServiceWorker(int thread_id, 114 void OnUpdateServiceWorker(int thread_id,
127 int request_id, 115 int request_id,
128 int provider_id, 116 int provider_id,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 const SourceInfo& source_info, 185 const SourceInfo& source_info,
198 const StatusCallback& callback, 186 const StatusCallback& callback,
199 ServiceWorkerStatusCode status); 187 ServiceWorkerStatusCode status);
200 void ReleaseSourceInfo(const ServiceWorkerClientInfo& source_info); 188 void ReleaseSourceInfo(const ServiceWorkerClientInfo& source_info);
201 void ReleaseSourceInfo(const ServiceWorkerObjectInfo& source_info); 189 void ReleaseSourceInfo(const ServiceWorkerObjectInfo& source_info);
202 190
203 ServiceWorkerRegistrationHandle* FindRegistrationHandle( 191 ServiceWorkerRegistrationHandle* FindRegistrationHandle(
204 int provider_id, 192 int provider_id,
205 int64_t registration_handle_id); 193 int64_t registration_handle_id);
206 194
195 void GetRegistrationObjectInfoAndVersionAttributes(
196 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
197 ServiceWorkerRegistration* registration,
198 ServiceWorkerRegistrationObjectInfo* info,
199 ServiceWorkerVersionAttributes* attrs);
200
207 // Callbacks from ServiceWorkerContextCore 201 // Callbacks from ServiceWorkerContextCore
208 void RegistrationComplete(int thread_id, 202 void RegistrationComplete(int thread_id,
209 int provider_id, 203 int provider_id,
210 int request_id, 204 int request_id,
211 ServiceWorkerStatusCode status, 205 ServiceWorkerStatusCode status,
212 const std::string& status_message, 206 const std::string& status_message,
213 int64_t registration_id); 207 int64_t registration_id);
214 void UpdateComplete(int thread_id, 208 void UpdateComplete(int thread_id,
215 int provider_id, 209 int provider_id,
216 int request_id, 210 int request_id,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 std::vector<std::unique_ptr<IPC::Message>> pending_messages_; 266 std::vector<std::unique_ptr<IPC::Message>> pending_messages_;
273 267
274 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_; 268 base::WeakPtrFactory<ServiceWorkerDispatcherHost> weak_factory_;
275 269
276 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost); 270 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost);
277 }; 271 };
278 272
279 } // namespace content 273 } // namespace content
280 274
281 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ 275 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698