OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_ | 5 #ifndef CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_ |
6 #define CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_ | 6 #define CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/child/worker_task_runner.h" | 11 #include "content/child/worker_task_runner.h" |
12 #include "third_party/WebKit/public/platform/WebNavigatorConnectProvider.h" | 12 #include "third_party/WebKit/public/platform/WebNavigatorConnectProvider.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
18 } | 18 } |
19 | 19 |
20 namespace blink { | 20 namespace blink { |
21 template <typename T1, typename T2> | |
22 class WebCallbacks; | |
23 class WebMessagePortChannel; | 21 class WebMessagePortChannel; |
24 class WebString; | 22 class WebString; |
25 } | 23 } |
26 | 24 |
27 namespace IPC { | 25 namespace IPC { |
28 class Message; | 26 class Message; |
29 } | 27 } |
30 | 28 |
31 namespace content { | 29 namespace content { |
32 class ThreadSafeSender; | 30 class ThreadSafeSender; |
(...skipping 10 matching lines...) Expand all Loading... |
43 public: | 41 public: |
44 NavigatorConnectProvider( | 42 NavigatorConnectProvider( |
45 ThreadSafeSender* thread_safe_sender, | 43 ThreadSafeSender* thread_safe_sender, |
46 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop); | 44 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop); |
47 ~NavigatorConnectProvider(); | 45 ~NavigatorConnectProvider(); |
48 | 46 |
49 // WebNavigatorConnectProvider implementation. | 47 // WebNavigatorConnectProvider implementation. |
50 virtual void connect(const blink::WebURL& target_url, | 48 virtual void connect(const blink::WebURL& target_url, |
51 const blink::WebString& origin, | 49 const blink::WebString& origin, |
52 blink::WebMessagePortChannel* port, | 50 blink::WebMessagePortChannel* port, |
53 blink::WebCallbacks<void, void>* callbacks); | 51 blink::WebNavigatorConnectCallbacks* callbacks); |
54 | 52 |
55 void OnMessageReceived(const IPC::Message& msg); | 53 void OnMessageReceived(const IPC::Message& msg); |
56 | 54 |
57 // |thread_safe_sender| and |main_loop| need to be passed in because if the | 55 // |thread_safe_sender| and |main_loop| need to be passed in because if the |
58 // call leads to construction they will be needed. | 56 // call leads to construction they will be needed. |
59 static NavigatorConnectProvider* ThreadSpecificInstance( | 57 static NavigatorConnectProvider* ThreadSpecificInstance( |
60 ThreadSafeSender* thread_safe_sender, | 58 ThreadSafeSender* thread_safe_sender, |
61 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop); | 59 const scoped_refptr<base::SingleThreadTaskRunner>& main_loop); |
62 | 60 |
63 private: | 61 private: |
64 void OnConnectResult(int thread_id, int request_id, bool allow_connect); | 62 void OnConnectResult(int thread_id, int request_id, bool allow_connect); |
65 | 63 |
66 // WorkerTaskRunner::Observer implementation. | 64 // WorkerTaskRunner::Observer implementation. |
67 void OnWorkerRunLoopStopped() override; | 65 void OnWorkerRunLoopStopped() override; |
68 | 66 |
69 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 67 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
70 scoped_refptr<base::SingleThreadTaskRunner> main_loop_; | 68 scoped_refptr<base::SingleThreadTaskRunner> main_loop_; |
71 typedef blink::WebCallbacks<void, void> ConnectCallback; | 69 typedef blink::WebNavigatorConnectCallbacks ConnectCallback; |
72 IDMap<ConnectCallback, IDMapOwnPointer> requests_; | 70 IDMap<ConnectCallback, IDMapOwnPointer> requests_; |
73 | 71 |
74 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectProvider); | 72 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectProvider); |
75 }; | 73 }; |
76 | 74 |
77 } // namespace content | 75 } // namespace content |
78 | 76 |
79 #endif // CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_ | 77 #endif // CONTENT_CHILD_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_PROVIDER_H_ |
OLD | NEW |