IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / renderer / service_worker / embedded_worker_context_client.h
blob7f789714f6173ddfc2610e04b997ee25ffbcc2b7
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_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_
6 #define CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string16.h"
10 #include "ipc/ipc_listener.h"
11 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h"
12 #include "url/gurl.h"
14 namespace base {
15 class MessageLoopProxy;
18 namespace content {
20 struct ServiceWorkerFetchRequest;
21 class ThreadSafeSender;
23 // This class provides access to/from an embedded worker's WorkerGlobalScope.
24 // All methods other than the constructor (it's created on the main thread)
25 // are called on the worker thread.
26 class EmbeddedWorkerContextClient
27 : public blink::WebServiceWorkerContextClient {
28 public:
29 // Returns a thread-specific client instance. This does NOT create a
30 // new instance.
31 static EmbeddedWorkerContextClient* ThreadSpecificInstance();
33 EmbeddedWorkerContextClient(int embedded_worker_id,
34 int64 service_worker_version_id,
35 const GURL& script_url);
37 virtual ~EmbeddedWorkerContextClient();
39 bool OnMessageReceived(const IPC::Message& msg);
41 // WebServiceWorkerContextClient overrides.
42 virtual void workerContextFailedToStart();
43 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy);
44 virtual void workerContextDestroyed();
46 // TODO: Implement DevTools related method overrides.
48 int embedded_worker_id() const { return embedded_worker_id_; }
50 private:
51 void OnFetchEvent(int thread_id,
52 int embedded_worker_id,
53 const ServiceWorkerFetchRequest& request);
55 const int embedded_worker_id_;
56 const int64 service_worker_version_id_;
57 const GURL script_url_;
58 scoped_refptr<ThreadSafeSender> sender_;
59 scoped_refptr<base::MessageLoopProxy> main_thread_proxy_;
61 blink::WebServiceWorkerContextProxy* proxy_;
63 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient);
66 } // namespace content
68 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_