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

Side by Side Diff: content/browser/service_worker/embedded_worker_registry.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
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_REGISTRY_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 21 matching lines...) Expand all
32 // EmbeddedWorkerInstance). Operated only on IO thread. 32 // EmbeddedWorkerInstance). Operated only on IO thread.
33 class CONTENT_EXPORT EmbeddedWorkerRegistry 33 class CONTENT_EXPORT EmbeddedWorkerRegistry
34 : public NON_EXPORTED_BASE(base::RefCounted<EmbeddedWorkerRegistry>) { 34 : public NON_EXPORTED_BASE(base::RefCounted<EmbeddedWorkerRegistry>) {
35 public: 35 public:
36 explicit EmbeddedWorkerRegistry( 36 explicit EmbeddedWorkerRegistry(
37 base::WeakPtr<ServiceWorkerContextCore> context); 37 base::WeakPtr<ServiceWorkerContextCore> context);
38 38
39 // Creates and removes a new worker instance entry for bookkeeping. 39 // Creates and removes a new worker instance entry for bookkeeping.
40 // This doesn't actually start or stop the worker. 40 // This doesn't actually start or stop the worker.
41 scoped_ptr<EmbeddedWorkerInstance> CreateWorker(); 41 scoped_ptr<EmbeddedWorkerInstance> CreateWorker();
42 void RemoveWorker(int embedded_worker_id);
43 42
44 // Called from EmbeddedWorkerInstance, relayed to the child process. 43 // Called from EmbeddedWorkerInstance, relayed to the child process.
45 bool StartWorker(int process_id, 44 bool StartWorker(int process_id,
46 int embedded_worker_id, 45 int embedded_worker_id,
47 int64 service_worker_version_id, 46 int64 service_worker_version_id,
48 const GURL& script_url); 47 const GURL& script_url);
49 bool StopWorker(int process_id, 48 bool StopWorker(int process_id,
50 int embedded_worker_id); 49 int embedded_worker_id);
51 50
51 // Called back from EmbeddedWorker in the child process, relayed via
52 // ServiceWorkerDispatcherHost.
53 void OnWorkerStarted(int process_id, int thread_id, int embedded_worker_id);
54 void OnWorkerStopped(int process_id, int embedded_worker_id);
55
52 // Keeps a map from process_id to sender information. 56 // Keeps a map from process_id to sender information.
53 void AddChildProcessSender(int process_id, IPC::Sender* sender); 57 void AddChildProcessSender(int process_id, IPC::Sender* sender);
54 void RemoveChildProcessSender(int process_id); 58 void RemoveChildProcessSender(int process_id);
55 59
56 private: 60 private:
57 friend class base::RefCounted<EmbeddedWorkerRegistry>; 61 friend class base::RefCounted<EmbeddedWorkerRegistry>;
62 friend class EmbeddedWorkerInstance;
63
64 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap;
65 typedef std::map<int, IPC::Sender*> ProcessToSenderMap;
58 66
59 ~EmbeddedWorkerRegistry(); 67 ~EmbeddedWorkerRegistry();
60 bool Send(int process_id, IPC::Message* message); 68 bool Send(int process_id, IPC::Message* message);
61 69
62 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap; 70 // RemoveWorker is called when EmbeddedWorkerInstance is destructed.
63 typedef std::map<int, IPC::Sender*> ProcessToSenderMap; 71 // |process_id| could be invalid (i.e. -1) if it's not running.
72 void RemoveWorker(int process_id, int embedded_worker_id);
64 73
65 base::WeakPtr<ServiceWorkerContextCore> context_; 74 base::WeakPtr<ServiceWorkerContextCore> context_;
66 75
67 WorkerInstanceMap worker_map_; 76 WorkerInstanceMap worker_map_;
68 ProcessToSenderMap process_sender_map_; 77 ProcessToSenderMap process_sender_map_;
69 78
79 // Map from process_id to embedded_worker_id.
80 // This map only contains running workers.
81 std::map<int, int> worker_process_map_;
82
70 int next_embedded_worker_id_; 83 int next_embedded_worker_id_;
71 84
72 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); 85 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry);
73 }; 86 };
74 87
75 } // namespace content 88 } // namespace content
76 89
77 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ 90 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698