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

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

Issue 85023003: EmbeddedWorker, browser side code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 7 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/logging.h"
13 #include "base/memory/ref_counted.h"
14
15 class GURL;
16
17 namespace content {
18
19 class EmbeddedWorkerRegistry;
20
21 // This gives an interface to control one EmbeddedWorker instance, which
22 // may be 'in-waiting' or running in one of the child processes added by
23 // AddProcessReference().
24 class EmbeddedWorkerInstance {
25 public:
26 enum Status {
27 STOPPED,
28 STARTING,
29 RUNNING,
30 STOPPING,
31 };
32
33 // This instance holds a ref of |registry|.
34 EmbeddedWorkerInstance(EmbeddedWorkerRegistry* registry,
35 int embedded_worker_id);
36 ~EmbeddedWorkerInstance();
37
38 // Starts the worker. It is invalid to call this when the worker is
39 // not in STOPPED status.
40 void Start(int64 service_worker_version_id,
41 const GURL& script_url);
42
43 // Stops the worker. It is invalid to call this when the worker is
44 // not in STARTING or RUNNING status.
45 void Stop();
46
47 // Called back from Registry.
alecflett 2013/12/05 05:18:42 Can you just explain when the registry calls these
kinuko 2013/12/09 14:07:42 Done. I assume eventually SWVersion will implemen
48 void OnStarted(int thread_id);
49 void OnStopped();
50
51 // Add or remove |process_id| to the internal process set where this
52 // worker can be started.
53 void AddProcessReference(int process_id);
54 void ReleaseProcessReference(int process_id);
55
56 int embedded_worker_id() const { return embedded_worker_id_; }
57 Status status() const { return status_; }
58 int process_id() const { return process_id_; }
59 int thread_id() const { return thread_id_; }
60
61 private:
62 typedef std::map<int, int> ProcessRefMap;
63
64 // Chooses a process to start this worker.
65 int ChooseProcess();
66
67 scoped_refptr<EmbeddedWorkerRegistry> registry_;
68 const int embedded_worker_id_;
69 Status status_;
70
71 // Current running information. -1 indicates the worker is not running.
72 int process_id_;
73 int thread_id_;
74
75 ProcessRefMap process_refs_;
76
77 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
78 };
79
80 } // namespace content
81
82 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698