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

Side by Side Diff: content/browser/navigator_connect/navigator_connect_dispatcher_host.h

Issue 861373002: Refactor navigator.connect code to make it more flexible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 5 years, 11 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
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_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H_
7 7
8 #include "content/common/service_worker/service_worker_status_code.h"
9 #include "content/public/browser/browser_message_filter.h" 8 #include "content/public/browser/browser_message_filter.h"
10 9
11 class GURL; 10 class GURL;
12 11
13 namespace content { 12 namespace content {
14 13
15 struct CrossOriginServiceWorkerClient; 14 struct NavigatorConnectClient;
16 class NavigatorConnectContext; 15 class NavigatorConnectContextImpl;
17 class ServiceWorkerContextWrapper;
18 class ServiceWorkerRegistration;
19 16
20 // Receives navigator.connect connection attempts from a child process. 17 // Receives navigator.connect connection attempts from a child process.
21 // Attempts to find a service that serves the URL the connection is made to 18 // Attempts to find a service that serves the URL the connection is made to
22 // and sets up the actual connection. 19 // and sets up the actual connection.
23 // Constructed on the UI thread, but all other methods are called on the IO 20 // Constructed on the UI thread, but all other methods are called on the IO
24 // thread. Typically there is one instance of this class for each renderer 21 // thread. Typically there is one instance of this class for each renderer
25 // process, and this class lives at least as long as the renderer process is 22 // process, and this class lives at least as long as the renderer process is
26 // alive (since this class is refcounted it could outlive the renderer process 23 // alive (since this class is refcounted it could outlive the renderer process
27 // if it is still handling a connection attempt). 24 // if it is still handling a connection attempt).
28 class NavigatorConnectDispatcherHost : public BrowserMessageFilter { 25 class NavigatorConnectDispatcherHost : public BrowserMessageFilter {
29 public: 26 public:
30 NavigatorConnectDispatcherHost( 27 explicit NavigatorConnectDispatcherHost(const scoped_refptr<
31 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context, 28 NavigatorConnectContextImpl>& navigator_connect_context);
32 const scoped_refptr<NavigatorConnectContext>& navigator_connect_context);
33 29
34 private: 30 private:
35 ~NavigatorConnectDispatcherHost() override; 31 ~NavigatorConnectDispatcherHost() override;
36 32
37 // BrowserMessageFilter implementation. 33 // BrowserMessageFilter implementation.
38 bool OnMessageReceived(const IPC::Message& message) override; 34 bool OnMessageReceived(const IPC::Message& message) override;
39 35
40 // IPC Message handlers. 36 // IPC Message handlers.
41 void OnConnect(int thread_id, 37 void OnConnect(int thread_id,
42 int request_id, 38 int request_id,
43 const CrossOriginServiceWorkerClient& client); 39 const NavigatorConnectClient& client);
44
45 // Callback called when the Service Worker context found (or didn't find) a
46 // service worker registration to serve a particular URL.
47 void GotServiceWorkerRegistration(
48 int thread_id,
49 int request_id,
50 const CrossOriginServiceWorkerClient& client,
51 ServiceWorkerStatusCode status,
52 const scoped_refptr<ServiceWorkerRegistration>& registration);
53 40
54 // Callback called when the service worker finished handling the cross origin 41 // Callback called when the service worker finished handling the cross origin
55 // connection event. 42 // connection event.
56 void OnConnectResult( 43 void OnConnectResult(
57 int thread_id, 44 int thread_id,
58 int request_id, 45 int request_id,
59 const CrossOriginServiceWorkerClient& client,
60 const scoped_refptr<ServiceWorkerRegistration>& registration,
61 ServiceWorkerStatusCode status,
62 bool accept_connection); 46 bool accept_connection);
63 47
64 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 48 scoped_refptr<NavigatorConnectContextImpl> navigator_connect_context_;
65 scoped_refptr<NavigatorConnectContext> navigator_connect_context_;
66 49
67 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectDispatcherHost); 50 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectDispatcherHost);
68 }; 51 };
69 52
70 } // namespace content 53 } // namespace content
71 54
72 #endif // CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H _ 55 #endif // CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698