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

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

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

Powered by Google App Engine
This is Rietveld 408576698