Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: content/browser/service_worker/service_worker_context_wrapper.h

Issue 251653003: Introduces DevToolsManagerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop using CallbackList Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "content/browser/service_worker/service_worker_context_core.h" 11 #include "content/browser/service_worker/service_worker_context_core.h"
12 #include "content/browser/service_worker/service_worker_context_observer.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 #include "content/public/browser/service_worker_context.h" 14 #include "content/public/browser/service_worker_context.h"
14 15
15 namespace base { 16 namespace base {
16 class FilePath; 17 class FilePath;
17 } 18 }
18 19
19 namespace quota { 20 namespace quota {
20 class QuotaManagerProxy; 21 class QuotaManagerProxy;
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 25
25 class ServiceWorkerContextObserver; 26 class ServiceWorkerContextObserver;
26 27
27 // A refcounted wrapper class for our core object. Higher level content lib 28 // A refcounted wrapper class for our core object. Higher level content lib
28 // classes keep references to this class on mutliple threads. The inner core 29 // classes keep references to this class on mutliple threads. The inner core
29 // instance is strictly single threaded and is not refcounted, the core object 30 // instance is strictly single threaded and is not refcounted, the core object
30 // is what is used internally in the service worker lib. 31 // is what is used internally in the service worker lib.
31 class CONTENT_EXPORT ServiceWorkerContextWrapper 32 class CONTENT_EXPORT ServiceWorkerContextWrapper
32 : NON_EXPORTED_BASE(public ServiceWorkerContext), 33 : NON_EXPORTED_BASE(public ServiceWorkerContext),
34 public ServiceWorkerContextObserver,
33 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { 35 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> {
34 public: 36 public:
35 ServiceWorkerContextWrapper(); 37 ServiceWorkerContextWrapper();
36 38
37 // Init and Shutdown are for use on the UI thread when the profile, 39 // Init and Shutdown are for use on the UI thread when the profile,
38 // storagepartition is being setup and torn down. 40 // storagepartition is being setup and torn down.
39 void Init(const base::FilePath& user_data_directory, 41 void Init(const base::FilePath& user_data_directory,
40 quota::QuotaManagerProxy* quota_manager_proxy); 42 quota::QuotaManagerProxy* quota_manager_proxy);
41 void Shutdown(); 43 void Shutdown();
42 44
43 // The core context is only for use on the IO thread. 45 // The core context is only for use on the IO thread.
44 ServiceWorkerContextCore* context(); 46 ServiceWorkerContextCore* context();
45 47
46 // ServiceWorkerContext implementation: 48 // ServiceWorkerContext implementation:
47 virtual void RegisterServiceWorker(const GURL& pattern, 49 virtual void RegisterServiceWorker(const GURL& pattern,
48 const GURL& script_url, 50 const GURL& script_url,
49 int source_process_id, 51 int source_process_id,
50 const ResultCallback& continuation) 52 const ResultCallback& continuation)
51 OVERRIDE; 53 OVERRIDE;
52 54
53 virtual void UnregisterServiceWorker(const GURL& pattern, 55 virtual void UnregisterServiceWorker(const GURL& pattern,
54 int source_process_id, 56 int source_process_id,
55 const ResultCallback& continuation) 57 const ResultCallback& continuation)
56 OVERRIDE; 58 OVERRIDE;
57 59
60 virtual void AddStatusChangeCallback(
61 const base::Callback<void(void)>& callback) OVERRIDE;
62
63 virtual void RemoveStatusChangeCallback(
64 const base::Callback<void(void)>& callback) OVERRIDE;
65
66 virtual void GetRunningServiceWorkerInfo(
67 const GetRunningServiceWorkerInfoCallback& callback) OVERRIDE;
68
69 // ServiceWorkerContextObserver
70 virtual void OnWorkerStarted(int64 version_id, int process_id, int thread_id);
71 virtual void OnWorkerStopped(int64 version_id, int process_id, int thread_id);
72 virtual void OnVersionStateChanged(int64 version_id);
73
58 void AddObserver(ServiceWorkerContextObserver* observer); 74 void AddObserver(ServiceWorkerContextObserver* observer);
59 void RemoveObserver(ServiceWorkerContextObserver* observer); 75 void RemoveObserver(ServiceWorkerContextObserver* observer);
60 76
61 private: 77 private:
62 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; 78 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
63 virtual ~ServiceWorkerContextWrapper(); 79 virtual ~ServiceWorkerContextWrapper();
64 80
81 void CallStatusChangeCallback();
82
65 scoped_ptr<ServiceWorkerContextCore> context_core_; 83 scoped_ptr<ServiceWorkerContextCore> context_core_;
66 scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > 84 scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
67 observer_list_; 85 observer_list_;
86 std::vector<base::Callback<void(void)> > status_change_callbacks_;
68 }; 87 };
69 88
70 } // namespace content 89 } // namespace content
71 90
72 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 91 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698