Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: content/renderer/service_worker/service_worker_context_client.h

Issue 54573002: Initial child-process side plumbing for starting an embedded ServiceWorker context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/service_worker/service_worker_context_client.h
diff --git a/content/renderer/service_worker/service_worker_context_client.h b/content/renderer/service_worker/service_worker_context_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..e59cc62a84ad73932d45de93fc677f9a4141a5f2
--- /dev/null
+++ b/content/renderer/service_worker/service_worker_context_client.h
@@ -0,0 +1,63 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_
+#define CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/strings/string16.h"
+#include "ipc/ipc_listener.h"
+#include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h"
+#include "url/gurl.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace content {
+
+class ThreadSafeSender;
+
+// This class provides access to/from an embedded worker's WorkerGlobalScope.
+// All methods other than the constructor (it's created on the main thread)
+// are called on the worker thread.
+class ServiceWorkerContextClient
+ : public blink::WebServiceWorkerContextClient {
+ public:
+ // Returns a thread-specific client instance. This does NOT create a
+ // new instance.
+ static ServiceWorkerContextClient* ThreadSpecificInstance();
+
+ ServiceWorkerContextClient(int embedded_worker_id,
+ int64 service_worker_version_id,
+ const GURL& script_url);
+
+ virtual ~ServiceWorkerContextClient();
+
+ bool OnMessageReceived(const IPC::Message& msg);
+
+ // WebServiceWorkerContextClient overrides.
+ virtual void workerContextFailedToStart();
+ virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy);
+ virtual void workerContextDestroyed();
+
+ // TODO: Implement DevTools related method overrides.
+
+ int embedded_worker_id() const { return embedded_worker_id_; }
+
+ private:
+ const int embedded_worker_id_;
+ const int64 service_worker_version_id_;
+ const GURL script_url_;
+ scoped_refptr<ThreadSafeSender> sender_;
+ scoped_refptr<base::MessageLoopProxy> main_thread_proxy_;
+
+ blink::WebServiceWorkerContextProxy* proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698