- add sources.
[platform/framework/web/crosswalk.git] / src / content / worker / worker_thread.h
1 // Copyright (c) 2012 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_WORKER_WORKER_THREAD_H_
6 #define CONTENT_WORKER_WORKER_THREAD_H_
7
8 #include <set>
9
10 #include "content/child/child_thread.h"
11
12 struct WorkerProcessMsg_CreateWorker_Params;
13
14 namespace content {
15 class AppCacheDispatcher;
16 class DBMessageFilter;
17 class IndexedDBMessageFilter;
18 class WebDatabaseObserverImpl;
19 class WebSharedWorkerStub;
20 class WorkerWebKitPlatformSupportImpl;
21
22 class WorkerThread : public ChildThread {
23  public:
24   WorkerThread();
25   virtual ~WorkerThread();
26   virtual void Shutdown() OVERRIDE;
27
28   // Returns the one worker thread.
29   static WorkerThread* current();
30
31   // Invoked from stub constructors/destructors. Stubs own themselves.
32   void AddWorkerStub(WebSharedWorkerStub* stub);
33   void RemoveWorkerStub(WebSharedWorkerStub* stub);
34
35   AppCacheDispatcher* appcache_dispatcher() {
36     return appcache_dispatcher_.get();
37   }
38
39  private:
40   virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
41   virtual void OnChannelError() OVERRIDE;
42   virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
43
44   void OnCreateWorker(const WorkerProcessMsg_CreateWorker_Params& params);
45   void OnShutdown();
46
47   scoped_ptr<WorkerWebKitPlatformSupportImpl> webkit_platform_support_;
48   scoped_ptr<AppCacheDispatcher> appcache_dispatcher_;
49   scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_;
50   scoped_refptr<DBMessageFilter> db_message_filter_;
51   scoped_refptr<IndexedDBMessageFilter> indexed_db_message_filter_;
52
53   typedef std::set<WebSharedWorkerStub*> WorkerStubsList;
54   WorkerStubsList worker_stubs_;
55
56   DISALLOW_COPY_AND_ASSIGN(WorkerThread);
57 };
58
59 }  // namespace content
60
61 #endif  // CONTENT_WORKER_WORKER_THREAD_H_