Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / service_worker / service_worker_context_wrapper.h
index 1b9b652..6b5b841 100644 (file)
@@ -5,14 +5,18 @@
 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
 
+#include <vector>
+
 #include "base/files/file_path.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/scoped_ptr.h"
-#include "content/browser/service_worker/service_worker_context.h"
+#include "content/browser/service_worker/service_worker_context_core.h"
 #include "content/common/content_export.h"
+#include "content/public/browser/service_worker_context.h"
 
 namespace base {
 class FilePath;
+class SequencedTaskRunner;
 }
 
 namespace quota {
@@ -21,7 +25,9 @@ class QuotaManagerProxy;
 
 namespace content {
 
+class BrowserContext;
 class ServiceWorkerContextCore;
+class ServiceWorkerContextObserver;
 
 // A refcounted wrapper class for our core object. Higher level content lib
 // classes keep references to this class on mutliple threads. The inner core
@@ -31,7 +37,7 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper
     : NON_EXPORTED_BASE(public ServiceWorkerContext),
       public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> {
  public:
-  ServiceWorkerContextWrapper();
+  ServiceWorkerContextWrapper(BrowserContext* browser_context);
 
   // Init and Shutdown are for use on the UI thread when the profile,
   // storagepartition is being setup and torn down.
@@ -42,10 +48,35 @@ class CONTENT_EXPORT ServiceWorkerContextWrapper
   // The core context is only for use on the IO thread.
   ServiceWorkerContextCore* context();
 
+  // ServiceWorkerContext implementation:
+  virtual void RegisterServiceWorker(
+      const GURL& pattern,
+      const GURL& script_url,
+      const ResultCallback& continuation) OVERRIDE;
+  virtual void UnregisterServiceWorker(const GURL& pattern,
+                                       const ResultCallback& continuation)
+      OVERRIDE;
+
+  void AddObserver(ServiceWorkerContextObserver* observer);
+  void RemoveObserver(ServiceWorkerContextObserver* observer);
+
  private:
   friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
+  friend class EmbeddedWorkerTestHelper;
+  friend class ServiceWorkerProcessManager;
   virtual ~ServiceWorkerContextWrapper();
 
+  void InitForTesting(const base::FilePath& user_data_directory,
+                      base::SequencedTaskRunner* database_task_runner,
+                      quota::QuotaManagerProxy* quota_manager_proxy);
+  void InitInternal(const base::FilePath& user_data_directory,
+                    base::SequencedTaskRunner* database_task_runner,
+                    quota::QuotaManagerProxy* quota_manager_proxy);
+
+  const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
+      observer_list_;
+  // Cleared in Shutdown():
+  BrowserContext* browser_context_;
   scoped_ptr<ServiceWorkerContextCore> context_core_;
 };