OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 #include "content/public/browser/worker_service.h" | 13 #include "content/public/browser/worker_service.h" |
14 | 14 |
| 15 struct ViewHostMsg_CreateWorker_Params; |
| 16 |
| 17 namespace IPC { |
| 18 class Message; |
| 19 } |
| 20 |
15 namespace content { | 21 namespace content { |
16 | 22 |
| 23 class SharedWorkerMessageFilter; |
| 24 class ResourceContext; |
17 class WorkerServiceObserver; | 25 class WorkerServiceObserver; |
| 26 class WorkerStoragePartition; |
18 | 27 |
19 // If "enable-embedded-shared-worker" is set this class will be used in stead of | 28 // If "enable-embedded-shared-worker" is set this class will be used instead of |
20 // WorkerServiceImpl. | 29 // WorkerServiceImpl. |
21 // TODO(horo): implement this class. | 30 // TODO(horo): implement this class. |
22 class CONTENT_EXPORT SharedWorkerServiceImpl | 31 class CONTENT_EXPORT SharedWorkerServiceImpl |
23 : public NON_EXPORTED_BASE(WorkerService) { | 32 : public NON_EXPORTED_BASE(WorkerService) { |
24 public: | 33 public: |
25 // Returns the SharedWorkerServiceImpl singleton. | 34 // Returns the SharedWorkerServiceImpl singleton. |
26 static SharedWorkerServiceImpl* GetInstance(); | 35 static SharedWorkerServiceImpl* GetInstance(); |
27 | 36 |
28 // WorkerService implementation: | 37 // WorkerService implementation: |
29 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; | 38 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; |
30 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; | 39 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; |
31 virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE; | 40 virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE; |
32 virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE; | 41 virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE; |
33 | 42 |
| 43 // These methods correspond to worker related IPCs. |
| 44 void CreateWorker(const ViewHostMsg_CreateWorker_Params& params, |
| 45 int route_id, |
| 46 SharedWorkerMessageFilter* filter, |
| 47 ResourceContext* resource_context, |
| 48 const WorkerStoragePartition& worker_partition, |
| 49 bool* url_mismatch); |
| 50 void ForwardToWorker(const IPC::Message& message, |
| 51 SharedWorkerMessageFilter* filter); |
| 52 void DocumentDetached(unsigned long long document_id, |
| 53 SharedWorkerMessageFilter* filter); |
| 54 void WorkerContextClosed(int worker_route_id, |
| 55 SharedWorkerMessageFilter* filter); |
| 56 void WorkerContextDestroyed(int worker_route_id, |
| 57 SharedWorkerMessageFilter* filter); |
| 58 void WorkerScriptLoaded(int worker_route_id, |
| 59 SharedWorkerMessageFilter* filter); |
| 60 void WorkerScriptLoadFailed(int worker_route_id, |
| 61 SharedWorkerMessageFilter* filter); |
| 62 void WorkerConnected(int message_port_id, |
| 63 int worker_route_id, |
| 64 SharedWorkerMessageFilter* filter); |
| 65 void AllowDatabase(int worker_route_id, |
| 66 const GURL& url, |
| 67 const base::string16& name, |
| 68 const base::string16& display_name, |
| 69 unsigned long estimated_size, |
| 70 bool* result, |
| 71 SharedWorkerMessageFilter* filter); |
| 72 void AllowFileSystem(int worker_route_id, |
| 73 const GURL& url, |
| 74 bool* result, |
| 75 SharedWorkerMessageFilter* filter); |
| 76 void AllowIndexedDB(int worker_route_id, |
| 77 const GURL& url, |
| 78 const base::string16& name, |
| 79 bool* result, |
| 80 SharedWorkerMessageFilter* filter); |
| 81 |
| 82 void OnSharedWorkerMessageFilterClosing( |
| 83 SharedWorkerMessageFilter* filter); |
| 84 |
34 private: | 85 private: |
35 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; | 86 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; |
36 | 87 |
37 SharedWorkerServiceImpl(); | 88 SharedWorkerServiceImpl(); |
38 virtual ~SharedWorkerServiceImpl(); | 89 virtual ~SharedWorkerServiceImpl(); |
39 | 90 |
40 ObserverList<WorkerServiceObserver> observers_; | 91 ObserverList<WorkerServiceObserver> observers_; |
41 | 92 |
42 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); | 93 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); |
43 }; | 94 }; |
44 | 95 |
45 } // namespace content | 96 } // namespace content |
46 | 97 |
47 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 98 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
OLD | NEW |