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 | |
21 namespace content { | 15 namespace content { |
22 | 16 |
23 class SharedWorkerMessageFilter; | |
24 class ResourceContext; | |
25 class WorkerServiceObserver; | 17 class WorkerServiceObserver; |
26 class WorkerStoragePartition; | |
27 | 18 |
28 // If "enable-embedded-shared-worker" is set this class will be used instead of | 19 // If "enable-embedded-shared-worker" is set this class will be used in stead of |
29 // WorkerServiceImpl. | 20 // WorkerServiceImpl. |
30 // TODO(horo): implement this class. | 21 // TODO(horo): implement this class. |
31 class CONTENT_EXPORT SharedWorkerServiceImpl | 22 class CONTENT_EXPORT SharedWorkerServiceImpl |
32 : public NON_EXPORTED_BASE(WorkerService) { | 23 : public NON_EXPORTED_BASE(WorkerService) { |
33 public: | 24 public: |
34 // Returns the SharedWorkerServiceImpl singleton. | 25 // Returns the SharedWorkerServiceImpl singleton. |
35 static SharedWorkerServiceImpl* GetInstance(); | 26 static SharedWorkerServiceImpl* GetInstance(); |
36 | 27 |
37 // WorkerService implementation: | 28 // WorkerService implementation: |
38 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; | 29 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; |
39 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; | 30 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; |
40 virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE; | 31 virtual void AddObserver(WorkerServiceObserver* observer) OVERRIDE; |
41 virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE; | 32 virtual void RemoveObserver(WorkerServiceObserver* observer) OVERRIDE; |
42 | 33 |
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 | |
85 private: | 34 private: |
86 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; | 35 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; |
87 | 36 |
88 SharedWorkerServiceImpl(); | 37 SharedWorkerServiceImpl(); |
89 virtual ~SharedWorkerServiceImpl(); | 38 virtual ~SharedWorkerServiceImpl(); |
90 | 39 |
91 ObserverList<WorkerServiceObserver> observers_; | 40 ObserverList<WorkerServiceObserver> observers_; |
92 | 41 |
93 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); | 42 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); |
94 }; | 43 }; |
95 | 44 |
96 } // namespace content | 45 } // namespace content |
97 | 46 |
98 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 47 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
OLD | NEW |