Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_context_wrapper.h
blob6b5b841ca638517065d64096cf5aa0980aeb5373
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
8 #include <vector>
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/browser/service_worker/service_worker_context_core.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/service_worker_context.h"
17 namespace base {
18 class FilePath;
19 class SequencedTaskRunner;
22 namespace quota {
23 class QuotaManagerProxy;
26 namespace content {
28 class BrowserContext;
29 class ServiceWorkerContextCore;
30 class ServiceWorkerContextObserver;
32 // A refcounted wrapper class for our core object. Higher level content lib
33 // classes keep references to this class on mutliple threads. The inner core
34 // instance is strictly single threaded and is not refcounted, the core object
35 // is what is used internally in the service worker lib.
36 class CONTENT_EXPORT ServiceWorkerContextWrapper
37 : NON_EXPORTED_BASE(public ServiceWorkerContext),
38 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> {
39 public:
40 ServiceWorkerContextWrapper(BrowserContext* browser_context);
42 // Init and Shutdown are for use on the UI thread when the profile,
43 // storagepartition is being setup and torn down.
44 void Init(const base::FilePath& user_data_directory,
45 quota::QuotaManagerProxy* quota_manager_proxy);
46 void Shutdown();
48 // The core context is only for use on the IO thread.
49 ServiceWorkerContextCore* context();
51 // ServiceWorkerContext implementation:
52 virtual void RegisterServiceWorker(
53 const GURL& pattern,
54 const GURL& script_url,
55 const ResultCallback& continuation) OVERRIDE;
56 virtual void UnregisterServiceWorker(const GURL& pattern,
57 const ResultCallback& continuation)
58 OVERRIDE;
60 void AddObserver(ServiceWorkerContextObserver* observer);
61 void RemoveObserver(ServiceWorkerContextObserver* observer);
63 private:
64 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
65 friend class EmbeddedWorkerTestHelper;
66 friend class ServiceWorkerProcessManager;
67 virtual ~ServiceWorkerContextWrapper();
69 void InitForTesting(const base::FilePath& user_data_directory,
70 base::SequencedTaskRunner* database_task_runner,
71 quota::QuotaManagerProxy* quota_manager_proxy);
72 void InitInternal(const base::FilePath& user_data_directory,
73 base::SequencedTaskRunner* database_task_runner,
74 quota::QuotaManagerProxy* quota_manager_proxy);
76 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
77 observer_list_;
78 // Cleared in Shutdown():
79 BrowserContext* browser_context_;
80 scoped_ptr<ServiceWorkerContextCore> context_core_;
83 } // namespace content
85 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_