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

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

Issue 140893002: Adding slightly clearer separation between SW and EmbeddedWorker (still incomplete) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added TODO to filter messages on the browser side Created 6 years, 11 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_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 13
14 class GURL; 14 class GURL;
15 15
16 namespace content { 16 namespace content {
17 17
18 class EmbeddedWorkerInstance; 18 class EmbeddedWorkerInstance;
19 class EmbeddedWorkerRegistry; 19 class EmbeddedWorkerRegistry;
20 class ServiceWorkerProviderHost; 20 class ServiceWorkerProviderHost;
21 class ServiceWorkerRegistration; 21 class ServiceWorkerRegistration;
22 struct ServiceWorkerFetchRequest;
22 23
23 // This class corresponds to a specific version of a ServiceWorker 24 // This class corresponds to a specific version of a ServiceWorker
24 // script for a given pattern. When a script is upgraded, there may be 25 // script for a given pattern. When a script is upgraded, there may be
25 // more than one ServiceWorkerVersion "running" at a time, but only 26 // more than one ServiceWorkerVersion "running" at a time, but only
26 // one of them is active. This class connects the actual script with a 27 // one of them is active. This class connects the actual script with a
27 // running worker. 28 // running worker.
28 // Instances of this class are in one of two install states: 29 // Instances of this class are in one of two install states:
29 // - Pending: The script is in the process of being installed. There 30 // - Pending: The script is in the process of being installed. There
30 // may be another active script running. 31 // may be another active script running.
31 // - Active: The script is the only worker handling requests for the 32 // - Active: The script is the only worker handling requests for the
(...skipping 30 matching lines...) Expand all
62 63
63 int64 version_id() const { return version_id_; } 64 int64 version_id() const { return version_id_; }
64 65
65 void Shutdown(); 66 void Shutdown();
66 bool is_shutdown() const { return is_shutdown_; } 67 bool is_shutdown() const { return is_shutdown_; }
67 68
68 // Starts and stops an embedded worker for this version. 69 // Starts and stops an embedded worker for this version.
69 void StartWorker(); 70 void StartWorker();
70 void StopWorker(); 71 void StopWorker();
71 72
73 // Sends fetch event to the associated embedded worker.
74 // This immediately returns false if the worker is not running
75 // or sending a message to the child process fails.
76 bool DispatchFetchEvent(const ServiceWorkerFetchRequest& request);
77
72 // Called when this version is associated to a provider host. 78 // Called when this version is associated to a provider host.
73 // Non-null |provider_host| must be given. 79 // Non-null |provider_host| must be given.
74 void OnAssociateProvider(ServiceWorkerProviderHost* provider_host); 80 void OnAssociateProvider(ServiceWorkerProviderHost* provider_host);
75 void OnUnassociateProvider(ServiceWorkerProviderHost* provider_host); 81 void OnUnassociateProvider(ServiceWorkerProviderHost* provider_host);
76 82
77 private: 83 private:
78 friend class base::RefCounted<ServiceWorkerVersion>; 84 friend class base::RefCounted<ServiceWorkerVersion>;
79 85
80 ~ServiceWorkerVersion(); 86 ~ServiceWorkerVersion();
81 87
82 const int64 version_id_; 88 const int64 version_id_;
83 89
84 bool is_shutdown_; 90 bool is_shutdown_;
85 scoped_refptr<ServiceWorkerRegistration> registration_; 91 scoped_refptr<ServiceWorkerRegistration> registration_;
86 92
87 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 93 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
88 94
89 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 95 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
90 }; 96 };
91 97
92 } // namespace content 98 } // namespace content
93 99
94 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 100 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698