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

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

Issue 1192713004: Update client side navigator.connect API to use ServicePortCollection [2/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 5 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 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 base {
17 class SingleThreadTaskRunner;
18 }
19
20 namespace blink {
21 class WebMessagePortChannel;
22 class WebString;
23 }
24
25 namespace IPC {
26 class Message;
27 }
28
29 namespace content {
30 class ThreadSafeSender;
31 struct TransferredMessagePort;
32
33 // Main entry point for the navigator.connect API in a child process. This
34 // implements the blink API and passes connect calls on to the browser process.
35 // NavigatorConnectDispatcher receives IPCs from the browser process and passes
36 // them on to the correct thread specific instance of this class.
37 // The ThreadSpecificInstance method will return an instance of this class for
38 // the current thread, or create one if no instance exists yet for this thread.
39 // This class deletes itself if the worker thread it belongs to quits.
40 class NavigatorConnectProvider : public blink::WebNavigatorConnectProvider,
41 public WorkerTaskRunner::Observer {
42 public:
43 NavigatorConnectProvider(
44 ThreadSafeSender* thread_safe_sender,
45 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop);
46 ~NavigatorConnectProvider();
47
48 // WebNavigatorConnectProvider implementation.
49 virtual void connect(const blink::WebURL& target_url,
50 const blink::WebString& origin,
51 blink::WebNavigatorConnectPortCallbacks* callbacks);
52
53 void OnMessageReceived(const IPC::Message& msg);
54
55 // |thread_safe_sender| and |main_loop| need to be passed in because if the
56 // call leads to construction they will be needed.
57 static NavigatorConnectProvider* ThreadSpecificInstance(
58 ThreadSafeSender* thread_safe_sender,
59 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop);
60
61 private:
62 void OnConnectResult(int thread_id,
63 int request_id,
64 const TransferredMessagePort& message_port,
65 int message_port_route_id,
66 bool allow_connect);
67
68 // WorkerTaskRunner::Observer implementation.
69 void OnWorkerRunLoopStopped() override;
70
71 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
72 scoped_refptr<base::SingleThreadTaskRunner> main_loop_;
73 IDMap<blink::WebNavigatorConnectPortCallbacks, IDMapOwnPointer> requests_;
74
75 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectProvider);
76 };
77
78 } // namespace content
79
80 #endif // CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698