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_RENDERER_WEBWORKER_BASE_H_ | 5 #ifndef CHROME_RENDERER_WEBWORKER_BASE_H_ |
6 #define CHROME_RENDERER_WEBWORKER_BASE_H_ | 6 #define CHROME_RENDERER_WEBWORKER_BASE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 void CreateWorkerContext(const GURL& script_url, | 29 void CreateWorkerContext(const GURL& script_url, |
30 bool is_shared, | 30 bool is_shared, |
31 const string16& name, | 31 const string16& name, |
32 const string16& user_agent, | 32 const string16& user_agent, |
33 const string16& source_code); | 33 const string16& source_code); |
34 | 34 |
35 // Returns true if the worker is running (can send messages to it). | 35 // Returns true if the worker is running (can send messages to it). |
36 bool IsStarted(); | 36 bool IsStarted(); |
37 | 37 |
38 // Disconnects the worker (stops listening for incoming messages). | 38 // Disconnects the worker (stops listening for incoming messages). |
39 virtual void Disconnect(); | 39 void Disconnect(); |
40 | 40 |
41 // Sends a message to the worker thread (forwarded via the RenderViewHost). | 41 // Sends a message to the worker thread (forwarded via the RenderViewHost). |
42 // If WorkerStarted() has not yet been called, message is queued. | 42 // If WorkerStarted() has not yet been called, message is queued. |
43 bool Send(IPC::Message*); | 43 bool Send(IPC::Message*); |
44 | 44 |
45 // Returns true if there are queued messages. | 45 // Returns true if there are queued messages. |
46 bool HasQueuedMessages() { return queued_messages_.size() != 0; } | 46 bool HasQueuedMessages() { return queued_messages_.size() != 0; } |
47 | 47 |
48 // Sends any messages currently in the queue. | 48 // Sends any messages currently in the queue. |
49 void SendQueuedMessages(); | 49 void SendQueuedMessages(); |
50 | 50 |
51 protected: | 51 protected: |
52 // Routing id associated with this worker - used to receive messages from the | 52 // Routing id associated with this worker - used to receive messages from the |
53 // worker, and also to route messages to the worker (WorkerService contains | 53 // worker, and also to route messages to the worker (WorkerService contains |
54 // a map that maps between these renderer-side route IDs and worker-side | 54 // a map that maps between these renderer-side route IDs and worker-side |
55 // routing ids). | 55 // routing ids). |
56 int route_id_; | 56 int route_id_; |
57 | 57 |
58 // The routing id for the RenderView that created this worker. | 58 // The routing id for the RenderView that created this worker. |
59 int render_view_route_id_; | 59 int render_view_route_id_; |
60 | 60 |
61 ChildThread* child_thread_; | 61 ChildThread* child_thread_; |
62 | 62 |
63 private: | 63 private: |
64 // Stores messages that were sent before the StartWorkerContext message. | 64 // Stores messages that were sent before the StartWorkerContext message. |
65 std::vector<IPC::Message*> queued_messages_; | 65 std::vector<IPC::Message*> queued_messages_; |
66 }; | 66 }; |
67 | 67 |
68 #endif // CHROME_RENDERER_WEBWORKER_BASE_H_ | 68 #endif // CHROME_RENDERER_WEBWORKER_BASE_H_ |
OLD | NEW |