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

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: #include <vector> 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 <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "content/browser/service_worker/service_worker_context_core.h" 13 #include "content/browser/service_worker/service_worker_context_core.h"
14 #include "content/browser/service_worker/service_worker_context_observer.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/public/browser/service_worker_context.h" 16 #include "content/public/browser/service_worker_context.h"
16 17
17 namespace base { 18 namespace base {
18 class FilePath; 19 class FilePath;
19 } 20 }
20 21
21 namespace quota { 22 namespace quota {
22 class QuotaManagerProxy; 23 class QuotaManagerProxy;
23 } 24 }
24 25
25 namespace content { 26 namespace content {
26 27
27 class BrowserContext; 28 class BrowserContext;
28 class ServiceWorkerContextCore; 29 class ServiceWorkerContextCore;
29 class ServiceWorkerContextObserver; 30 class ServiceWorkerContextObserver;
30 31
31 // A refcounted wrapper class for our core object. Higher level content lib 32 // A refcounted wrapper class for our core object. Higher level content lib
32 // classes keep references to this class on mutliple threads. The inner core 33 // classes keep references to this class on mutliple threads. The inner core
33 // instance is strictly single threaded and is not refcounted, the core object 34 // instance is strictly single threaded and is not refcounted, the core object
34 // is what is used internally in the service worker lib. 35 // is what is used internally in the service worker lib.
35 class CONTENT_EXPORT ServiceWorkerContextWrapper 36 class CONTENT_EXPORT ServiceWorkerContextWrapper
36 : NON_EXPORTED_BASE(public ServiceWorkerContext), 37 : NON_EXPORTED_BASE(public ServiceWorkerContext),
38 public ServiceWorkerContextObserver,
37 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { 39 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> {
38 public: 40 public:
39 ServiceWorkerContextWrapper(BrowserContext* browser_context); 41 ServiceWorkerContextWrapper(BrowserContext* browser_context);
40 42
41 // Init and Shutdown are for use on the UI thread when the profile, 43 // Init and Shutdown are for use on the UI thread when the profile,
42 // storagepartition is being setup and torn down. 44 // storagepartition is being setup and torn down.
43 void Init(const base::FilePath& user_data_directory, 45 void Init(const base::FilePath& user_data_directory,
44 quota::QuotaManagerProxy* quota_manager_proxy); 46 quota::QuotaManagerProxy* quota_manager_proxy);
45 void Shutdown(); 47 void Shutdown();
46 48
47 // The core context is only for use on the IO thread. 49 // The core context is only for use on the IO thread.
48 ServiceWorkerContextCore* context(); 50 ServiceWorkerContextCore* context();
49 51
50 // ServiceWorkerContext implementation: 52 // ServiceWorkerContext implementation:
51 virtual void RegisterServiceWorker( 53 virtual void RegisterServiceWorker(
52 const GURL& pattern, 54 const GURL& pattern,
53 const GURL& script_url, 55 const GURL& script_url,
54 const ResultCallback& continuation) OVERRIDE; 56 const ResultCallback& continuation) OVERRIDE;
55 virtual void UnregisterServiceWorker(const GURL& pattern, 57 virtual void UnregisterServiceWorker(
56 const ResultCallback& continuation) 58 const GURL& pattern,
57 OVERRIDE; 59 const ResultCallback& continuation) OVERRIDE;
60 virtual void AddStatusChangeObserver(
61 StatusChangeObserver* observer) OVERRIDE;
62 virtual void RemoveStatusChangeObserver(
63 StatusChangeObserver* observer) OVERRIDE;
64 virtual void GetRunningServiceWorkerInfo(
65 const GetRunningServiceWorkerInfoCallback& callback) OVERRIDE;
58 66
59 void AddObserver(ServiceWorkerContextObserver* observer); 67 void AddObserver(ServiceWorkerContextObserver* observer);
60 void RemoveObserver(ServiceWorkerContextObserver* observer); 68 void RemoveObserver(ServiceWorkerContextObserver* observer);
61 69
62 private: 70 private:
63 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; 71 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
64 friend class ServiceWorkerProcessManager; 72 friend class ServiceWorkerProcessManager;
65 virtual ~ServiceWorkerContextWrapper(); 73 virtual ~ServiceWorkerContextWrapper();
66 74
75 // ServiceWorkerContextObserver
76 virtual void OnWorkerStarted(int64 version_id,
77 int process_id,
78 int thread_id) OVERRIDE;
79 virtual void OnWorkerStopped(int64 version_id,
80 int process_id,
81 int thread_id) OVERRIDE;
82 virtual void OnVersionStateChanged(int64 version_id) OVERRIDE;
83
84 void NotifyStatusChangeObservers();
85
67 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > 86 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
68 observer_list_; 87 observer_list_;
88 ObserverList<StatusChangeObserver> status_change_observers_;
69 // Cleared in Shutdown(): 89 // Cleared in Shutdown():
70 BrowserContext* browser_context_; 90 BrowserContext* browser_context_;
71 scoped_ptr<ServiceWorkerContextCore> context_core_; 91 scoped_ptr<ServiceWorkerContextCore> context_core_;
72 }; 92 };
73 93
74 } // namespace content 94 } // namespace content
75 95
76 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 96 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698