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

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

Issue 238043002: Teach EmbeddedWorkerInstance to create a process when it needs one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle 2 places where context_ could be NULL. 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 | Annotate | Revision Log
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>
9
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "content/browser/service_worker/service_worker_context_core.h" 13 #include "content/browser/service_worker/service_worker_context_core.h"
12 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
13 #include "content/public/browser/service_worker_context.h" 15 #include "content/public/browser/service_worker_context.h"
14 16
15 namespace base { 17 namespace base {
16 class FilePath; 18 class FilePath;
17 } 19 }
18 20
19 namespace quota { 21 namespace quota {
20 class QuotaManagerProxy; 22 class QuotaManagerProxy;
21 } 23 }
22 24
23 namespace content { 25 namespace content {
24 26
27 class BrowserContext;
28 class ServiceWorkerContextCore;
25 class ServiceWorkerContextObserver; 29 class ServiceWorkerContextObserver;
26 30
27 // A refcounted wrapper class for our core object. Higher level content lib 31 // 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 32 // 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 33 // instance is strictly single threaded and is not refcounted, the core object
30 // is what is used internally in the service worker lib. 34 // is what is used internally in the service worker lib.
31 class CONTENT_EXPORT ServiceWorkerContextWrapper 35 class CONTENT_EXPORT ServiceWorkerContextWrapper
32 : NON_EXPORTED_BASE(public ServiceWorkerContext), 36 : NON_EXPORTED_BASE(public ServiceWorkerContext),
33 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { 37 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> {
34 public: 38 public:
35 ServiceWorkerContextWrapper(); 39 ServiceWorkerContextWrapper(BrowserContext* browser_context);
36 40
37 // Init and Shutdown are for use on the UI thread when the profile, 41 // Init and Shutdown are for use on the UI thread when the profile,
38 // storagepartition is being setup and torn down. 42 // storagepartition is being setup and torn down.
39 void Init(const base::FilePath& user_data_directory, 43 void Init(const base::FilePath& user_data_directory,
40 quota::QuotaManagerProxy* quota_manager_proxy); 44 quota::QuotaManagerProxy* quota_manager_proxy);
41 void Shutdown(); 45 void Shutdown();
42 46
43 // The core context is only for use on the IO thread. 47 // The core context is only for use on the IO thread.
44 ServiceWorkerContextCore* context(); 48 ServiceWorkerContextCore* context();
45 49
46 // ServiceWorkerContext implementation: 50 // ServiceWorkerContext implementation:
47 virtual void RegisterServiceWorker(const GURL& pattern, 51 virtual void RegisterServiceWorker(
48 const GURL& script_url, 52 const GURL& pattern,
49 int source_process_id, 53 const GURL& script_url,
50 const ResultCallback& continuation) 54 const ResultCallback& continuation) OVERRIDE;
51 OVERRIDE;
52
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
58 void AddObserver(ServiceWorkerContextObserver* observer); 60 void AddObserver(ServiceWorkerContextObserver* observer);
59 void RemoveObserver(ServiceWorkerContextObserver* observer); 61 void RemoveObserver(ServiceWorkerContextObserver* observer);
60 62
61 private: 63 private:
62 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; 64 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
65 friend class ServiceWorkerProcessManager;
63 virtual ~ServiceWorkerContextWrapper(); 66 virtual ~ServiceWorkerContextWrapper();
64 67
68 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
69 observer_list_;
70 // Cleared in Shutdown():
71 BrowserContext* browser_context_;
65 scoped_ptr<ServiceWorkerContextCore> context_core_; 72 scoped_ptr<ServiceWorkerContextCore> context_core_;
66 scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
67 observer_list_;
68 }; 73 };
69 74
70 } // namespace content 75 } // namespace content
71 76
72 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 77 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698