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

Side by Side Diff: chrome/renderer/webworker_base.h

Issue 6713005: Move a bunch of gpu/worker/plugin renderer code to content. I temporarily disabled the sad plugi... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/websharedworkerrepository_impl.cc ('k') | chrome/renderer/webworker_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_RENDERER_WEBWORKER_BASE_H_
6 #define CHROME_RENDERER_WEBWORKER_BASE_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "ipc/ipc_channel.h"
13
14 class ChildThread;
15 class GURL;
16
17 // WebWorkerBase is the common base class used by both WebWorkerProxy and
18 // WebSharedWorker. It contains logic to support starting up both dedicated
19 // and shared workers, and handling message queueing while waiting for the
20 // worker process to start.
21 class WebWorkerBase : public IPC::Channel::Listener {
22 public:
23 virtual ~WebWorkerBase();
24
25 // Creates and initializes a new dedicated worker context.
26 void CreateDedicatedWorkerContext(const GURL& script_url,
27 const string16& user_agent,
28 const string16& source_code) {
29 CreateWorkerContext(script_url, false, string16(), user_agent,
30 source_code, MSG_ROUTING_NONE, 0);
31 }
32
33 // Creates and initializes a new shared worker context.
34 void CreateSharedWorkerContext(const GURL& script_url,
35 const string16& name,
36 const string16& user_agent,
37 const string16& source_code,
38 int pending_route_id,
39 int64 script_resource_appcache_id) {
40 CreateWorkerContext(script_url, true, name, user_agent,
41 source_code, pending_route_id,
42 script_resource_appcache_id);
43 }
44
45 // Returns true if the worker is running (can send messages to it).
46 bool IsStarted();
47
48 // Disconnects the worker (stops listening for incoming messages).
49 void Disconnect();
50
51 // Sends a message to the worker thread (forwarded via the RenderViewHost).
52 // If WorkerStarted() has not yet been called, message is queued.
53 bool Send(IPC::Message*);
54
55 // Returns true if there are queued messages.
56 bool HasQueuedMessages() { return !queued_messages_.empty(); }
57
58 // Sends any messages currently in the queue.
59 void SendQueuedMessages();
60
61 protected:
62 WebWorkerBase(ChildThread* child_thread,
63 unsigned long long document_id,
64 int route_id,
65 int render_view_route_id,
66 int parent_appcache_host_id);
67
68 // Routing id associated with this worker - used to receive messages from the
69 // 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
71 // routing ids).
72 int route_id_;
73
74 // The routing id for the RenderView that created this worker.
75 int render_view_route_id_;
76
77 ChildThread* child_thread_;
78
79 private:
80 void CreateWorkerContext(const GURL& script_url,
81 bool is_shared,
82 const string16& name,
83 const string16& user_agent,
84 const string16& source_code,
85 int pending_route_id,
86 int64 script_resource_appcache_id);
87
88 // ID of our parent document (used to shutdown workers when the parent
89 // document is detached).
90 unsigned long long document_id_;
91
92 // ID of our parent's appcache host, only valid for dedicated workers.
93 int parent_appcache_host_id_;
94
95 // Stores messages that were sent before the StartWorkerContext message.
96 std::vector<IPC::Message*> queued_messages_;
97 };
98
99 #endif // CHROME_RENDERER_WEBWORKER_BASE_H_
OLDNEW
« no previous file with comments | « chrome/renderer/websharedworkerrepository_impl.cc ('k') | chrome/renderer/webworker_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698