#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 {
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
: 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.
// 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_;
};