OLD | NEW |
(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_SERVICE_WORKER_NAVIGATOR_CONNECT_PROVIDER_H_ |
| 6 #define CONTENT_CHILD_SERVICE_WORKER_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 |
| 13 class GURL; |
| 14 |
| 15 namespace blink { |
| 16 template <typename T1, typename T2> |
| 17 class WebCallbacks; |
| 18 class WebMessagePortChannel; |
| 19 class WebString; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 class ThreadSafeSender; |
| 24 |
| 25 class NavigatorConnectProvider : public WorkerTaskRunner::Observer { |
| 26 public: |
| 27 explicit NavigatorConnectProvider(ThreadSafeSender* thread_safe_sender); |
| 28 ~NavigatorConnectProvider(); |
| 29 |
| 30 void ConnectToUrl(const GURL& targetUrl, |
| 31 blink::WebMessagePortChannel* port, |
| 32 blink::WebCallbacks<void, blink::WebString>* callbacks); |
| 33 |
| 34 void OnNavigatorConnectResult(int thread_id, |
| 35 int request_id, |
| 36 bool allow_connect); |
| 37 |
| 38 // |thread_safe_sender| needs to be passed in because if the call leads to |
| 39 // construction it will be needed. |
| 40 static NavigatorConnectProvider* ThreadSpecificInstance( |
| 41 ThreadSafeSender* thread_safe_sender); |
| 42 |
| 43 private: |
| 44 // WorkerTaskRunner::Observer implementation. |
| 45 void OnWorkerRunLoopStopped() override; |
| 46 |
| 47 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 48 typedef blink::WebCallbacks<void, blink::WebString> ConnectCallback; |
| 49 IDMap<ConnectCallback> requests_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectProvider); |
| 52 }; |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_CHILD_SERVICE_WORKER_NAVIGATOR_CONNECT_PROVIDER_H_ |
OLD | NEW |