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

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

Issue 118103002: Add IPC stubs between browser and ServiceWorker's worker context in the child process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_EMBEDDED_WORKER_INSTANCE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 16
17 class GURL; 17 class GURL;
18 18
19 namespace content { 19 namespace content {
20 20
21 class EmbeddedWorkerRegistry; 21 class EmbeddedWorkerRegistry;
22 struct ServiceWorkerFetchRequest;
22 23
23 // This gives an interface to control one EmbeddedWorker instance, which 24 // This gives an interface to control one EmbeddedWorker instance, which
24 // may be 'in-waiting' or running in one of the child processes added by 25 // may be 'in-waiting' or running in one of the child processes added by
25 // AddProcessReference(). 26 // AddProcessReference().
26 class CONTENT_EXPORT EmbeddedWorkerInstance { 27 class CONTENT_EXPORT EmbeddedWorkerInstance {
27 public: 28 public:
28 enum Status { 29 enum Status {
29 STOPPED, 30 STOPPED,
30 STARTING, 31 STARTING,
31 RUNNING, 32 RUNNING,
32 STOPPING, 33 STOPPING,
33 }; 34 };
34 35
35 ~EmbeddedWorkerInstance(); 36 ~EmbeddedWorkerInstance();
36 37
37 // Starts the worker. It is invalid to call this when the worker is 38 // Starts the worker. It is invalid to call this when the worker is
38 // not in STOPPED status. 39 // not in STOPPED status.
39 // This returns false if starting a worker fails immediately, e.g. when 40 // This returns false if starting a worker fails immediately, e.g. when
40 // IPC couldn't be sent to the worker or no process was available. 41 // IPC couldn't be sent to the worker or no process was available.
41 bool Start(int64 service_worker_version_id, 42 bool Start(int64 service_worker_version_id,
42 const GURL& script_url); 43 const GURL& script_url);
43 44
44 // Stops the worker. It is invalid to call this when the worker is 45 // Stops the worker. It is invalid to call this when the worker is
45 // not in STARTING or RUNNING status. 46 // not in STARTING or RUNNING status.
46 // This returns false if stopping a worker fails immediately, e.g. when 47 // This returns false if stopping a worker fails immediately, e.g. when
47 // IPC couldn't be sent to the worker. 48 // IPC couldn't be sent to the worker.
48 bool Stop(); 49 bool Stop();
49 50
51 // Sends |request| to the embedded worker running in the child process.
52 // This returns false if sending IPC fails.
53 // It is invalid to call this while the worker is not in RUNNING status.
54 bool SendFetchRequest(const ServiceWorkerFetchRequest& request);
55
50 // Add or remove |process_id| to the internal process set where this 56 // Add or remove |process_id| to the internal process set where this
51 // worker can be started. 57 // worker can be started.
52 void AddProcessReference(int process_id); 58 void AddProcessReference(int process_id);
53 void ReleaseProcessReference(int process_id); 59 void ReleaseProcessReference(int process_id);
54 60
55 int embedded_worker_id() const { return embedded_worker_id_; } 61 int embedded_worker_id() const { return embedded_worker_id_; }
56 Status status() const { return status_; } 62 Status status() const { return status_; }
57 int process_id() const { return process_id_; } 63 int process_id() const { return process_id_; }
58 int thread_id() const { return thread_id_; } 64 int thread_id() const { return thread_id_; }
59 65
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 int thread_id_; 99 int thread_id_;
94 100
95 ProcessRefMap process_refs_; 101 ProcessRefMap process_refs_;
96 102
97 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); 103 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
98 }; 104 };
99 105
100 } // namespace content 106 } // namespace content
101 107
102 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ 108 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/embedded_worker_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698