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

Side by Side Diff: extensions/renderer/worker_thread_dispatcher.h

Issue 1880933002: Begin to enable extension APIs in Extension Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @tott Created 4 years, 7 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 EXTENSIONS_RENDERER_WORKER_THREAD_DISPATCHER_H_
6 #define EXTENSIONS_RENDERER_WORKER_THREAD_DISPATCHER_H_
7
8 #include "base/synchronization/lock.h"
9 #include "content/public/renderer/render_thread_observer.h"
10 #include "ipc/ipc_sync_message_filter.h"
11
12 namespace base {
13 class ListValue;
14 }
15
16 namespace content {
17 class RenderThread;
18 }
19
20 namespace extensions {
21 class RequestSender;
22 class V8SchemaRegistry;
23
24 // Sends and receives IPC in an extension Service Worker.
25 // TODO(lazyboy): This class should really be a combination of the following
26 // two:
27 // 1) A content::WorkerThreadMessageFilter, so that we can receive IPC directly
28 // on worker thread.
29 // 2) A content::ThreadSafeSender, so we can safely send IPC from worker thread.
30 class WorkerThreadDispatcher : public content::RenderThreadObserver {
31 public:
32 WorkerThreadDispatcher();
33 ~WorkerThreadDispatcher() override;
34
35 // Thread safe.
36 static WorkerThreadDispatcher* Get();
37 static RequestSender* GetRequestSender();
38
39 void Init(content::RenderThread* render_thread);
40 bool Send(IPC::Message* message);
41 void AddWorkerData(int embedded_worker_id);
42 void RemoveWorkerData(int embedded_worker_id);
43 V8SchemaRegistry* GetV8SchemaRegistry();
44
45 private:
46 // content::RenderThreadObserver:
47 bool OnControlMessageReceived(const IPC::Message& message) override;
48
49 // IPC handlers.
50 void OnResponseWorker(int worker_thread_id,
51 int request_id,
52 bool succeeded,
53 const base::ListValue& response,
54 const std::string& error);
55
56 // IPC sender. Belongs to the render thread, but thread safe.
57 scoped_refptr<IPC::SyncMessageFilter> message_filter_;
58
59 DISALLOW_COPY_AND_ASSIGN(WorkerThreadDispatcher);
60 };
61
62 } // namespace extensions
63
64 #endif // EXTENSIONS_RENDERER_WORKER_THREAD_DISPATCHER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/service_worker_request_sender.cc ('k') | extensions/renderer/worker_thread_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698