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

Side by Side Diff: chrome/browser/worker_host/worker_service.h

Issue 441022: Changed shared worker code so incognito windows do not have access to non-incognito shared workers. (Closed)
Patch Set: Removed superfluous valgrind change. Created 11 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ 5 #ifndef CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
6 #define CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ 6 #define CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 // Returns the WorkerService singleton. 22 // Returns the WorkerService singleton.
23 static WorkerService* GetInstance(); 23 static WorkerService* GetInstance();
24 24
25 // Initialize the WorkerService. OK to be called multiple times. 25 // Initialize the WorkerService. OK to be called multiple times.
26 void Initialize(ResourceDispatcherHost* rdh); 26 void Initialize(ResourceDispatcherHost* rdh);
27 27
28 // Creates a dedicated worker. Returns true on success. 28 // Creates a dedicated worker. Returns true on success.
29 bool CreateWorker(const GURL &url, 29 bool CreateWorker(const GURL &url,
30 bool is_shared, 30 bool is_shared,
31 bool is_off_the_record,
31 const string16& name, 32 const string16& name,
32 int renderer_pid, 33 int renderer_pid,
33 int render_view_route_id, 34 int render_view_route_id,
34 IPC::Message::Sender* sender, 35 IPC::Message::Sender* sender,
35 int sender_route_id); 36 int sender_route_id);
36 37
37 // Validates the passed URL and checks for the existence of matching shared 38 // Validates the passed URL and checks for the existence of matching shared
38 // worker. Returns true if the url was found, and sets the url_mismatch out 39 // worker. Returns true if the url was found, and sets the url_mismatch out
39 // param to true/false depending on whether there's a url mismatch with an 40 // param to true/false depending on whether there's a url mismatch with an
40 // existing shared worker with the same name. 41 // existing shared worker with the same name.
41 bool LookupSharedWorker(const GURL &url, 42 bool LookupSharedWorker(const GURL &url,
42 const string16& name, 43 const string16& name,
44 bool off_the_record,
43 unsigned long long document_id, 45 unsigned long long document_id,
44 IPC::Message::Sender* sender, 46 IPC::Message::Sender* sender,
45 int sender_route_id, 47 int sender_route_id,
46 bool* url_mismatch); 48 bool* url_mismatch);
47 49
48 // Notification from the renderer that a given document has detached, so any 50 // Notification from the renderer that a given document has detached, so any
49 // associated shared workers can be shut down. 51 // associated shared workers can be shut down.
50 void DocumentDetached(IPC::Message::Sender* sender, 52 void DocumentDetached(IPC::Message::Sender* sender,
51 unsigned long long document_id); 53 unsigned long long document_id);
52 54
53 // Cancel creation of a dedicated worker that hasn't started yet. 55 // Cancel creation of a dedicated worker that hasn't started yet.
54 void CancelCreateDedicatedWorker(IPC::Message::Sender* sender, 56 void CancelCreateDedicatedWorker(IPC::Message::Sender* sender,
55 int sender_route_id); 57 int sender_route_id);
56 58
57 // Called by the worker creator when a message arrives that should be 59 // Called by the worker creator when a message arrives that should be
58 // forwarded to the worker process. 60 // forwarded to the worker process.
59 void ForwardMessage(const IPC::Message& message, 61 void ForwardMessage(const IPC::Message& message,
60 IPC::Message::Sender* sender); 62 IPC::Message::Sender* sender);
61 63
62 int next_worker_route_id() { return ++next_worker_route_id_; } 64 int next_worker_route_id() { return ++next_worker_route_id_; }
63 65
64 // TODO(dimich): This code assumes there is 1 worker per worker process, which 66 // TODO(dimich): This code assumes there is 1 worker per worker process, which
65 // is how it is today until V8 can run in separate threads. 67 // is how it is today until V8 can run in separate threads.
66 const WorkerProcessHost::WorkerInstance* FindWorkerInstance( 68 const WorkerProcessHost::WorkerInstance* FindWorkerInstance(
67 int worker_process_id); 69 int worker_process_id);
68 70
69 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance( 71 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance(
70 const GURL& url, const string16& name); 72 const GURL& url, const string16& name, bool off_the_record);
71 73
72 // Used when multiple workers can run in the same process. 74 // Used when multiple workers can run in the same process.
73 static const int kMaxWorkerProcessesWhenSharing; 75 static const int kMaxWorkerProcessesWhenSharing;
74 76
75 // Used when we run each worker in a separate process. 77 // Used when we run each worker in a separate process.
76 static const int kMaxWorkersWhenSeparate; 78 static const int kMaxWorkersWhenSeparate;
77 static const int kMaxWorkersPerTabWhenSeparate; 79 static const int kMaxWorkersPerTabWhenSeparate;
78 80
79 private: 81 private:
80 friend struct DefaultSingletonTraits<WorkerService>; 82 friend struct DefaultSingletonTraits<WorkerService>;
(...skipping 24 matching lines...) Expand all
105 const NotificationDetails& details); 107 const NotificationDetails& details);
106 108
107 // Notifies us that a process that's talking to a worker has shut down. 109 // Notifies us that a process that's talking to a worker has shut down.
108 void SenderShutdown(IPC::Message::Sender* sender); 110 void SenderShutdown(IPC::Message::Sender* sender);
109 111
110 // Notifies us that a worker process has closed. 112 // Notifies us that a worker process has closed.
111 void WorkerProcessDestroyed(WorkerProcessHost* process); 113 void WorkerProcessDestroyed(WorkerProcessHost* process);
112 114
113 // APIs for manipulating our set of pending shared worker instances. 115 // APIs for manipulating our set of pending shared worker instances.
114 WorkerProcessHost::WorkerInstance* CreatePendingInstance( 116 WorkerProcessHost::WorkerInstance* CreatePendingInstance(
115 const GURL& url, const string16& name); 117 const GURL& url, const string16& name, bool off_the_record);
116 WorkerProcessHost::WorkerInstance* FindPendingInstance( 118 WorkerProcessHost::WorkerInstance* FindPendingInstance(
117 const GURL& url, const string16& name); 119 const GURL& url, const string16& name, bool off_the_record);
118 void RemovePendingInstance(const GURL& url, const string16& name); 120 void RemovePendingInstance(
121 const GURL& url, const string16& name, bool off_the_record);
119 122
120 NotificationRegistrar registrar_; 123 NotificationRegistrar registrar_;
121 int next_worker_route_id_; 124 int next_worker_route_id_;
122 ResourceDispatcherHost* resource_dispatcher_host_; 125 ResourceDispatcherHost* resource_dispatcher_host_;
123 126
124 WorkerProcessHost::Instances queued_workers_; 127 WorkerProcessHost::Instances queued_workers_;
125 128
126 // These are shared workers that have been looked up, but not created yet. 129 // These are shared workers that have been looked up, but not created yet.
127 // We need to keep a list of these to synchronously detect shared worker 130 // We need to keep a list of these to synchronously detect shared worker
128 // URL mismatches when two pages launch shared workers simultaneously. 131 // URL mismatches when two pages launch shared workers simultaneously.
129 WorkerProcessHost::Instances pending_shared_workers_; 132 WorkerProcessHost::Instances pending_shared_workers_;
130 133
131 DISALLOW_COPY_AND_ASSIGN(WorkerService); 134 DISALLOW_COPY_AND_ASSIGN(WorkerService);
132 }; 135 };
133 136
134 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ 137 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698