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

Side by Side Diff: content/child/navigator_connect/navigator_connect_provider.h

Issue 781723002: Pass navigator.connect calls through to the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years 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 2014 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_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_
6 #define CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/id_map.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/child/worker_task_runner.h"
12 #include "third_party/WebKit/public/platform/WebNavigatorConnectProvider.h"
13
14 class GURL;
15
16 namespace blink {
17 template <typename T1, typename T2>
18 class WebCallbacks;
19 class WebMessagePortChannel;
20 class WebString;
21 }
22
23 namespace IPC {
24 class Message;
25 }
26
27 namespace content {
28 class ThreadSafeSender;
29
30 // Main entry point for the navigator.connect API in a child process. This
31 // implements the blink API and passes connect calls on to the browser process.
32 // NavigatorConnectDispatcher receives IPCs from the browser process and passes
33 // them on to the correct thread specific instance of this class.
34 // The ThreadSpecificInstance method will return an instance of this class for
35 // the current thread, or create one if no instance exists yet for this thread.
36 // This class deletes itself if the worker thread it belongs to quits.
37 class NavigatorConnectProvider : public blink::WebNavigatorConnectProvider,
38 public WorkerTaskRunner::Observer {
39 public:
40 explicit NavigatorConnectProvider(ThreadSafeSender* thread_safe_sender);
41 ~NavigatorConnectProvider();
42
43 // WebNavigatorConnectProvider implementation.
44 virtual void connect(const blink::WebURL& targetUrl,
45 blink::WebMessagePortChannel* port,
46 blink::WebCallbacks<void, void>* callbacks);
47
48 void OnMessageReceived(const IPC::Message& msg);
49
50 // |thread_safe_sender| needs to be passed in because if the call leads to
51 // construction it will be needed.
52 static NavigatorConnectProvider* ThreadSpecificInstance(
53 ThreadSafeSender* thread_safe_sender);
54
55 private:
56 void OnConnectResult(int thread_id, int request_id, bool allow_connect);
57
58 // WorkerTaskRunner::Observer implementation.
59 void OnWorkerRunLoopStopped() override;
60
61 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
62 typedef blink::WebCallbacks<void, void> ConnectCallback;
63 IDMap<ConnectCallback> requests_;
64
65 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectProvider);
66 };
67
68 } // namespace content
69
70 #endif // CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698