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

Side by Side Diff: chrome/browser/worker_host/worker_process_host.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_PROCESS_HOST_H_ 5 #ifndef CHROME_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
6 #define CHROME_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ 6 #define CHROME_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "chrome/common/child_process_host.h" 12 #include "chrome/common/child_process_host.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "ipc/ipc_channel.h" 14 #include "ipc/ipc_channel.h"
15 15
16 class WorkerProcessHost : public ChildProcessHost { 16 class WorkerProcessHost : public ChildProcessHost {
17 public: 17 public:
18 // Contains information about each worker instance, needed to forward messages 18 // Contains information about each worker instance, needed to forward messages
19 // between the renderer and worker processes. 19 // between the renderer and worker processes.
20 class WorkerInstance { 20 class WorkerInstance {
21 public: 21 public:
22 WorkerInstance(const GURL& url, 22 WorkerInstance(const GURL& url,
23 bool is_shared, 23 bool is_shared,
24 bool is_off_the_record,
24 const string16& name, 25 const string16& name,
25 int renderer_id, 26 int renderer_id,
26 int render_view_route_id, 27 int render_view_route_id,
27 int worker_route_id); 28 int worker_route_id);
28 29
29 // Unique identifier for a worker client. 30 // Unique identifier for a worker client.
30 typedef std::pair<IPC::Message::Sender*, int> SenderInfo; 31 typedef std::pair<IPC::Message::Sender*, int> SenderInfo;
31 32
32 // APIs to manage the sender list for a given instance. 33 // APIs to manage the sender list for a given instance.
33 void AddSender(IPC::Message::Sender* sender, int sender_route_id); 34 void AddSender(IPC::Message::Sender* sender, int sender_route_id);
34 void RemoveSender(IPC::Message::Sender* sender, int sender_route_id); 35 void RemoveSender(IPC::Message::Sender* sender, int sender_route_id);
35 void RemoveSenders(IPC::Message::Sender* sender); 36 void RemoveSenders(IPC::Message::Sender* sender);
36 bool HasSender(IPC::Message::Sender* sender, int sender_route_id) const; 37 bool HasSender(IPC::Message::Sender* sender, int sender_route_id) const;
37 int NumSenders() const { return senders_.size(); } 38 int NumSenders() const { return senders_.size(); }
38 // Returns the single sender (must only be one). 39 // Returns the single sender (must only be one).
39 SenderInfo GetSender() const; 40 SenderInfo GetSender() const;
40 41
41 // Checks if this WorkerInstance matches the passed url/name params 42 // Checks if this WorkerInstance matches the passed url/name params
42 // (per the comparison algorithm in the WebWorkers spec). This API only 43 // (per the comparison algorithm in the WebWorkers spec). This API only
43 // applies to shared workers. 44 // applies to shared workers.
44 bool Matches(const GURL& url, const string16& name) const; 45 bool Matches(
46 const GURL& url, const string16& name, bool off_the_record) const;
45 47
46 // Adds a document to a shared worker's document set. 48 // Adds a document to a shared worker's document set.
47 void AddToDocumentSet(IPC::Message::Sender* parent, 49 void AddToDocumentSet(IPC::Message::Sender* parent,
48 unsigned long long document_id); 50 unsigned long long document_id);
49 51
50 // Checks to see if a document is in a shared worker's document set. 52 // Checks to see if a document is in a shared worker's document set.
51 bool IsInDocumentSet(IPC::Message::Sender* parent, 53 bool IsInDocumentSet(IPC::Message::Sender* parent,
52 unsigned long long document_id) const; 54 unsigned long long document_id) const;
53 55
54 // Removes a specific document from a shared worker's document set when 56 // Removes a specific document from a shared worker's document set when
55 // that document is detached. 57 // that document is detached.
56 void RemoveFromDocumentSet(IPC::Message::Sender* parent, 58 void RemoveFromDocumentSet(IPC::Message::Sender* parent,
57 unsigned long long document_id); 59 unsigned long long document_id);
58 60
59 // Copies the document set from one instance to another 61 // Copies the document set from one instance to another
60 void CopyDocumentSet(const WorkerInstance& instance) { 62 void CopyDocumentSet(const WorkerInstance& instance) {
61 document_set_ = instance.document_set_; 63 document_set_ = instance.document_set_;
62 }; 64 };
63 65
64 // Invoked when a render process exits, to remove all associated documents 66 // Invoked when a render process exits, to remove all associated documents
65 // from a shared worker's document set. 67 // from a shared worker's document set.
66 void RemoveAllAssociatedDocuments(IPC::Message::Sender* parent); 68 void RemoveAllAssociatedDocuments(IPC::Message::Sender* parent);
67 69
68 bool IsDocumentSetEmpty() const { return document_set_.empty(); } 70 bool IsDocumentSetEmpty() const { return document_set_.empty(); }
69 71
70 72
71 // Accessors 73 // Accessors
72 bool is_shared() const { return shared_; } 74 bool is_shared() const { return shared_; }
75 bool is_off_the_record() const { return off_the_record_; }
jam 2009/11/25 23:30:46 nit: I should have mentioned this last time, but s
73 bool is_closed() const { return closed_; } 76 bool is_closed() const { return closed_; }
74 void set_closed(bool closed) { closed_ = closed; } 77 void set_closed(bool closed) { closed_ = closed; }
75 const GURL& url() const { return url_; } 78 const GURL& url() const { return url_; }
76 const string16 name() const { return name_; } 79 const string16 name() const { return name_; }
77 int renderer_id() const { return renderer_id_; } 80 int renderer_id() const { return renderer_id_; }
78 int render_view_route_id() const { return render_view_route_id_; } 81 int render_view_route_id() const { return render_view_route_id_; }
79 int worker_route_id() const { return worker_route_id_; } 82 int worker_route_id() const { return worker_route_id_; }
80 83
81 private: 84 private:
82 // Unique identifier for an associated document. 85 // Unique identifier for an associated document.
83 typedef std::pair<IPC::Message::Sender*, unsigned long long> DocumentInfo; 86 typedef std::pair<IPC::Message::Sender*, unsigned long long> DocumentInfo;
84 typedef std::list<DocumentInfo> DocumentSet; 87 typedef std::list<DocumentInfo> DocumentSet;
85 // Set of all senders (clients) associated with this worker. 88 // Set of all senders (clients) associated with this worker.
86 typedef std::list<SenderInfo> SenderList; 89 typedef std::list<SenderInfo> SenderList;
87 GURL url_; 90 GURL url_;
88 bool shared_; 91 bool shared_;
92 bool off_the_record_;
89 bool closed_; 93 bool closed_;
90 string16 name_; 94 string16 name_;
91 int renderer_id_; 95 int renderer_id_;
92 int render_view_route_id_; 96 int render_view_route_id_;
93 int worker_route_id_; 97 int worker_route_id_;
94 SenderList senders_; 98 SenderList senders_;
95 DocumentSet document_set_; 99 DocumentSet document_set_;
96 }; 100 };
97 101
98 explicit WorkerProcessHost(ResourceDispatcherHost* resource_dispatcher_host_); 102 explicit WorkerProcessHost(ResourceDispatcherHost* resource_dispatcher_host_);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 171
168 Instances instances_; 172 Instances instances_;
169 173
170 // A callback to create a routing id for the associated worker process. 174 // A callback to create a routing id for the associated worker process.
171 scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_; 175 scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_;
172 176
173 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost); 177 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost);
174 }; 178 };
175 179
176 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ 180 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698