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 CONTENT_RENDERER_WEBWORKER_BASE_H_ | 5 #ifndef CONTENT_RENDERER_WEBWORKER_BASE_H_ |
6 #define CONTENT_RENDERER_WEBWORKER_BASE_H_ | 6 #define CONTENT_RENDERER_WEBWORKER_BASE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/scoped_ptr.h" |
12 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
13 | 15 |
14 class ChildThread; | 16 class ChildThread; |
15 class GURL; | 17 class GURL; |
| 18 class WorkerDevToolsAgentProxy; |
16 | 19 |
17 // WebWorkerBase is the common base class used by both WebWorkerProxy and | 20 // WebWorkerBase is the common base class used by both WebWorkerProxy and |
18 // WebSharedWorker. It contains logic to support starting up both dedicated | 21 // WebSharedWorker. It contains logic to support starting up both dedicated |
19 // and shared workers, and handling message queueing while waiting for the | 22 // and shared workers, and handling message queueing while waiting for the |
20 // worker process to start. | 23 // worker process to start. |
21 class WebWorkerBase : public IPC::Channel::Listener { | 24 class WebWorkerBase : public IPC::Channel::Listener { |
22 public: | 25 public: |
23 virtual ~WebWorkerBase(); | 26 virtual ~WebWorkerBase(); |
24 | 27 |
25 // Creates and initializes a new dedicated worker context. | 28 // Creates and initializes a new dedicated worker context. |
(...skipping 30 matching lines...) Expand all Loading... |
56 bool HasQueuedMessages() { return !queued_messages_.empty(); } | 59 bool HasQueuedMessages() { return !queued_messages_.empty(); } |
57 | 60 |
58 // Sends any messages currently in the queue. | 61 // Sends any messages currently in the queue. |
59 void SendQueuedMessages(); | 62 void SendQueuedMessages(); |
60 | 63 |
61 protected: | 64 protected: |
62 WebWorkerBase(ChildThread* child_thread, | 65 WebWorkerBase(ChildThread* child_thread, |
63 unsigned long long document_id, | 66 unsigned long long document_id, |
64 int route_id, | 67 int route_id, |
65 int render_view_route_id, | 68 int render_view_route_id, |
66 int parent_appcache_host_id); | 69 int parent_appcache_host_id, |
| 70 WorkerDevToolsAgentProxy*); |
67 | 71 |
68 // Routing id associated with this worker - used to receive messages from the | 72 // Routing id associated with this worker - used to receive messages from the |
69 // worker, and also to route messages to the worker (WorkerService contains | 73 // worker, and also to route messages to the worker (WorkerService contains |
70 // a map that maps between these renderer-side route IDs and worker-side | 74 // a map that maps between these renderer-side route IDs and worker-side |
71 // routing ids). | 75 // routing ids). |
72 int route_id_; | 76 int route_id_; |
73 | 77 |
74 // The routing id for the RenderView that created this worker. | 78 // The routing id for the RenderView that created this worker. |
75 int render_view_route_id_; | 79 int render_view_route_id_; |
76 | 80 |
77 ChildThread* child_thread_; | 81 ChildThread* child_thread_; |
78 | 82 |
| 83 scoped_ptr<WorkerDevToolsAgentProxy> devtools_proxy_; |
| 84 |
79 private: | 85 private: |
80 void CreateWorkerContext(const GURL& script_url, | 86 void CreateWorkerContext(const GURL& script_url, |
81 bool is_shared, | 87 bool is_shared, |
82 const string16& name, | 88 const string16& name, |
83 const string16& user_agent, | 89 const string16& user_agent, |
84 const string16& source_code, | 90 const string16& source_code, |
85 int pending_route_id, | 91 int pending_route_id, |
86 int64 script_resource_appcache_id); | 92 int64 script_resource_appcache_id); |
87 | 93 |
88 // ID of our parent document (used to shutdown workers when the parent | 94 // ID of our parent document (used to shutdown workers when the parent |
89 // document is detached). | 95 // document is detached). |
90 unsigned long long document_id_; | 96 unsigned long long document_id_; |
91 | 97 |
92 // ID of our parent's appcache host, only valid for dedicated workers. | 98 // ID of our parent's appcache host, only valid for dedicated workers. |
93 int parent_appcache_host_id_; | 99 int parent_appcache_host_id_; |
94 | 100 |
95 // Stores messages that were sent before the StartWorkerContext message. | 101 // Stores messages that were sent before the StartWorkerContext message. |
96 std::vector<IPC::Message*> queued_messages_; | 102 std::vector<IPC::Message*> queued_messages_; |
97 }; | 103 }; |
98 | 104 |
99 #endif // CONTENT_RENDERER_WEBWORKER_BASE_H_ | 105 #endif // CONTENT_RENDERER_WEBWORKER_BASE_H_ |
OLD | NEW |