OLD | NEW |
(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_WORKER_WORKER_THREAD_H_ |
| 6 #define CHROME_WORKER_WORKER_THREAD_H_ |
| 7 |
| 8 #include "base/thread.h" |
| 9 #include "chrome/common/ipc_sync_channel.h" |
| 10 #include "chrome/common/message_router.h" |
| 11 #include "chrome/common/resource_dispatcher.h" |
| 12 |
| 13 class WebWorkerContextStub; |
| 14 class WorkerProcess; |
| 15 |
| 16 class WorkerThread : public IPC::Channel::Listener, |
| 17 public IPC::Message::Sender, |
| 18 public base::Thread { |
| 19 public: |
| 20 WorkerThread(WorkerProcess *process, const std::wstring& channel_name); |
| 21 ~WorkerThread(); |
| 22 |
| 23 // IPC::Channel::Listener implementation: |
| 24 virtual void OnMessageReceived(const IPC::Message& msg); |
| 25 virtual void OnChannelError(); |
| 26 |
| 27 // IPC::Message::Sender implementation: |
| 28 virtual bool Send(IPC::Message* msg); |
| 29 |
| 30 void OnWorkerDestruction(WebWorkerContextStub* worker); |
| 31 |
| 32 private: |
| 33 // Thread implementation: |
| 34 void Init(); |
| 35 void CleanUp(); |
| 36 |
| 37 void OnCreateWorker(const GURL& url, int route_id); |
| 38 |
| 39 // The process that has created this thread |
| 40 WorkerProcess *worker_process_; |
| 41 |
| 42 // The message loop used to run tasks on the thread that started this thread. |
| 43 MessageLoop* owner_loop_; |
| 44 |
| 45 std::wstring channel_name_; |
| 46 scoped_ptr<IPC::SyncChannel> channel_; |
| 47 |
| 48 // Used to implement message routing functionality to |
| 49 // WebWorkerContextProxyStub objects. |
| 50 MessageRouter router_; |
| 51 |
| 52 DISALLOW_EVIL_CONSTRUCTORS(WorkerThread); |
| 53 }; |
| 54 |
| 55 #endif // CHROME_WORKER_WORKER_THREAD_H_ |
OLD | NEW |