| OLD | NEW |
| 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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // APIs to manage the sender list for a given instance. | 35 // APIs to manage the sender list for a given instance. |
| 36 void AddSender(IPC::Message::Sender* sender, int sender_route_id); | 36 void AddSender(IPC::Message::Sender* sender, int sender_route_id); |
| 37 void RemoveSender(IPC::Message::Sender* sender, int sender_route_id); | 37 void RemoveSender(IPC::Message::Sender* sender, int sender_route_id); |
| 38 void RemoveSenders(IPC::Message::Sender* sender); | 38 void RemoveSenders(IPC::Message::Sender* sender); |
| 39 bool HasSender(IPC::Message::Sender* sender, int sender_route_id) const; | 39 bool HasSender(IPC::Message::Sender* sender, int sender_route_id) const; |
| 40 bool RendererIsParent(int renderer_id, int render_view_route_id) const; | 40 bool RendererIsParent(int renderer_id, int render_view_route_id) const; |
| 41 int NumSenders() const { return senders_.size(); } | 41 int NumSenders() const { return senders_.size(); } |
| 42 // Returns the single sender (must only be one). | 42 // Returns the single sender (must only be one). |
| 43 SenderInfo GetSender() const; | 43 SenderInfo GetSender() const; |
| 44 | 44 |
| 45 typedef std::list<SenderInfo> SenderList; |
| 46 const SenderList& senders() const { return senders_; } |
| 47 |
| 45 // Checks if this WorkerInstance matches the passed url/name params | 48 // Checks if this WorkerInstance matches the passed url/name params |
| 46 // (per the comparison algorithm in the WebWorkers spec). This API only | 49 // (per the comparison algorithm in the WebWorkers spec). This API only |
| 47 // applies to shared workers. | 50 // applies to shared workers. |
| 48 bool Matches( | 51 bool Matches( |
| 49 const GURL& url, const string16& name, bool off_the_record) const; | 52 const GURL& url, const string16& name, bool off_the_record) const; |
| 50 | 53 |
| 51 // Shares the passed instance's WorkerDocumentSet with this instance. This | 54 // Shares the passed instance's WorkerDocumentSet with this instance. This |
| 52 // instance's current WorkerDocumentSet is dereferenced (and freed if this | 55 // instance's current WorkerDocumentSet is dereferenced (and freed if this |
| 53 // is the only reference) as a result. | 56 // is the only reference) as a result. |
| 54 void ShareDocumentSet(const WorkerInstance& instance) { | 57 void ShareDocumentSet(const WorkerInstance& instance) { |
| 55 worker_document_set_ = instance.worker_document_set_; | 58 worker_document_set_ = instance.worker_document_set_; |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 // Accessors | 61 // Accessors |
| 59 bool shared() const { return shared_; } | 62 bool shared() const { return shared_; } |
| 60 bool off_the_record() const { return off_the_record_; } | 63 bool off_the_record() const { return off_the_record_; } |
| 61 bool closed() const { return closed_; } | 64 bool closed() const { return closed_; } |
| 62 void set_closed(bool closed) { closed_ = closed; } | 65 void set_closed(bool closed) { closed_ = closed; } |
| 63 const GURL& url() const { return url_; } | 66 const GURL& url() const { return url_; } |
| 64 const string16 name() const { return name_; } | 67 const string16 name() const { return name_; } |
| 65 int worker_route_id() const { return worker_route_id_; } | 68 int worker_route_id() const { return worker_route_id_; } |
| 66 WorkerDocumentSet* worker_document_set() const { | 69 WorkerDocumentSet* worker_document_set() const { |
| 67 return worker_document_set_; | 70 return worker_document_set_; |
| 68 } | 71 } |
| 69 | 72 |
| 70 private: | 73 private: |
| 71 // Set of all senders (clients) associated with this worker. | 74 // Set of all senders (clients) associated with this worker. |
| 72 typedef std::list<SenderInfo> SenderList; | |
| 73 GURL url_; | 75 GURL url_; |
| 74 bool shared_; | 76 bool shared_; |
| 75 bool off_the_record_; | 77 bool off_the_record_; |
| 76 bool closed_; | 78 bool closed_; |
| 77 string16 name_; | 79 string16 name_; |
| 78 int worker_route_id_; | 80 int worker_route_id_; |
| 79 SenderList senders_; | 81 SenderList senders_; |
| 80 scoped_refptr<WorkerDocumentSet> worker_document_set_; | 82 scoped_refptr<WorkerDocumentSet> worker_document_set_; |
| 81 }; | 83 }; |
| 82 | 84 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 152 |
| 151 Instances instances_; | 153 Instances instances_; |
| 152 | 154 |
| 153 // A callback to create a routing id for the associated worker process. | 155 // A callback to create a routing id for the associated worker process. |
| 154 scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_; | 156 scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_; |
| 155 | 157 |
| 156 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost); | 158 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost); |
| 157 }; | 159 }; |
| 158 | 160 |
| 159 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ | 161 #endif // CHROME_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ |
| OLD | NEW |