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

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: rebase 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(const GURL& pattern,
michaeln 2014/05/01 02:52:07 while you're here, can you make the line wrapping
horo 2014/05/01 04:52:32 Done.
56 int source_process_id, 58 int source_process_id,
57 const ResultCallback& continuation) 59 const ResultCallback& continuation)
58 OVERRIDE; 60 OVERRIDE;
59 61
62 virtual void AddStatusChangeCallback(
63 const base::Callback<void(void)>& callback) OVERRIDE;
64
65 virtual void RemoveStatusChangeCallback(
66 const base::Callback<void(void)>& callback) OVERRIDE;
67
68 virtual void GetRunningServiceWorkerInfo(
69 const GetRunningServiceWorkerInfoCallback& callback) OVERRIDE;
70
71 // ServiceWorkerContextObserver
michaeln 2014/05/01 02:52:07 can these go in the private section since it's rea
horo 2014/05/01 04:52:32 Done.
72 virtual void OnWorkerStarted(int64 version_id, int process_id, int thread_id);
73 virtual void OnWorkerStopped(int64 version_id, int process_id, int thread_id);
74 virtual void OnVersionStateChanged(int64 version_id);
75
60 void AddObserver(ServiceWorkerContextObserver* observer); 76 void AddObserver(ServiceWorkerContextObserver* observer);
61 void RemoveObserver(ServiceWorkerContextObserver* observer); 77 void RemoveObserver(ServiceWorkerContextObserver* observer);
62 78
63 private: 79 private:
64 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; 80 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
65 friend class ServiceWorkerProcessManager; 81 friend class ServiceWorkerProcessManager;
66 virtual ~ServiceWorkerContextWrapper(); 82 virtual ~ServiceWorkerContextWrapper();
67 83
84 void CallStatusChangeCallback();
85
68 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > 86 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
69 observer_list_; 87 observer_list_;
70 // Cleared in Shutdown(): 88 // Cleared in Shutdown():
71 BrowserContext* browser_context_; 89 BrowserContext* browser_context_;
72 scoped_ptr<ServiceWorkerContextCore> context_core_; 90 scoped_ptr<ServiceWorkerContextCore> context_core_;
91 std::vector<base::Callback<void(void)> > status_change_callbacks_;
73 }; 92 };
74 93
75 } // namespace content 94 } // namespace content
76 95
77 #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