Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / child / service_worker / web_service_worker_provider_impl.h
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.
4
5 #ifndef CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_PROVIDER_IMPL_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_PROVIDER_IMPL_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/WebKit/public/platform/WebServiceWorkerProvider.h"
12
13 namespace blink {
14 class WebURL;
15 class WebServiceWorkerProviderClient;
16 }
17
18 namespace content {
19
20 class ServiceWorkerDispatcher;
21 class ServiceWorkerProviderContext;
22 class ThreadSafeSender;
23
24 // This class corresponds to one ServiceWorkerContainer interface in
25 // JS context (i.e. navigator.serviceWorker).
26 class WebServiceWorkerProviderImpl
27     : NON_EXPORTED_BASE(public blink::WebServiceWorkerProvider) {
28  public:
29   WebServiceWorkerProviderImpl(ThreadSafeSender* thread_safe_sender,
30                                ServiceWorkerProviderContext* context);
31   virtual ~WebServiceWorkerProviderImpl();
32
33   virtual void setClient(blink::WebServiceWorkerProviderClient* client);
34
35   virtual void registerServiceWorker(const blink::WebURL& pattern,
36                                      const blink::WebURL& script_url,
37                                      WebServiceWorkerCallbacks*);
38
39   virtual void unregisterServiceWorker(const blink::WebURL& pattern,
40                                        WebServiceWorkerCallbacks*);
41
42   ServiceWorkerProviderContext* context() { return context_.get(); }
43
44  private:
45   void RemoveScriptClient();
46   ServiceWorkerDispatcher* GetDispatcher();
47
48   scoped_refptr<ThreadSafeSender> thread_safe_sender_;
49   scoped_refptr<ServiceWorkerProviderContext> context_;
50   const int provider_id_;
51
52   DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerProviderImpl);
53 };
54
55 }  // namespace content
56
57 #endif  // CONTENT_CHILD_SERVICE_WORKER_WEB_SERVICE_WORKER_PROVIDER_IMPL_H_