diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 18:11:47 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 18:11:47 +0000 |
commit | ab3505360bf6612d18915a39a0fec74b00642e82 (patch) | |
tree | 7a39d15a688b8e52c839fb9151851b2a37533ed0 /chrome/renderer/webworker_base.h | |
parent | 06b9e3b77773477b5ee889ded41d10741d6b0647 (diff) | |
download | chromium_src-ab3505360bf6612d18915a39a0fec74b00642e82.zip chromium_src-ab3505360bf6612d18915a39a0fec74b00642e82.tar.gz chromium_src-ab3505360bf6612d18915a39a0fec74b00642e82.tar.bz2 |
Initial pass of shared workers renderer-side code
Added initial interface hooks betweek WebKit code and renderer-side worker code.
The proper messages are generated to fire off a shared worker, but they are currently
ignored by the browser process.
BUG=26233
TEST=none (will enable layout tests when basic functionality available)
Review URL: http://codereview.chromium.org/340036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/webworker_base.h')
-rw-r--r-- | chrome/renderer/webworker_base.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/chrome/renderer/webworker_base.h b/chrome/renderer/webworker_base.h new file mode 100644 index 0000000..c7c6c62 --- /dev/null +++ b/chrome/renderer/webworker_base.h @@ -0,0 +1,64 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_RENDERER_WEBWORKER_BASE_H_ +#define CHROME_RENDERER_WEBWORKER_BASE_H_ + +#include <vector> + +#include "base/basictypes.h" +#include "ipc/ipc_channel.h" + +class ChildThread; +class GURL; + +// WebWorkerBase is the common base class used by both WebWorkerProxy and +// WebSharedWorker. It contains logic to support starting up both dedicated +// and shared workers, and handling message queueing while waiting for the +// worker process to start. +class WebWorkerBase : public IPC::Channel::Listener { + public: + WebWorkerBase(ChildThread* child_thread, + int route_id, + int render_view_route_id); + + virtual ~WebWorkerBase(); + + // Creates and initializes a new worker context. + void CreateWorkerContext(IPC::Message* create_message, + const GURL& script_url, + const string16& user_agent, + const string16& source_code); + + // Returns true if the worker is running (can send messages to it). + bool IsStarted(); + + // Disconnects the worker (stops listening for incoming messages). + virtual void Disconnect(); + + // Sends a message to the worker thread (forwarded via the RenderViewHost). + // If WorkerStarted() has not yet been called, message is queued. + bool Send(IPC::Message*); + + // Sends any messages currently in the queue. + void SendQueuedMessages(); + + protected: + // Routing id associated with this worker - used to receive messages from the + // worker, and also to route messages to the worker (WorkerService contains + // a map that maps between these renderer-side route IDs and worker-side + // routing ids). + int route_id_; + + // The routing id for the RenderView that created this worker. + int render_view_route_id_; + + ChildThread* child_thread_; + + private: + // Stores messages that were sent before the StartWorkerContext message. + std::vector<IPC::Message*> queued_messages_; +}; + +#endif // CHROME_RENDERER_WEBWORKER_BASE_H_ |