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

Side by Side Diff: remoting/host/setup/me2me_native_messaging_host.h

Issue 103693006: Me2me Native Messaging host on Windows: restructure NativeMessagingHost and NativeMessagingChannel.… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_ 5 #ifndef REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_
6 #define REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_ 6 #define REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 10 matching lines...) Expand all
21 namespace gaia { 21 namespace gaia {
22 class GaiaOAuthClient; 22 class GaiaOAuthClient;
23 } // namespace gaia 23 } // namespace gaia
24 24
25 namespace remoting { 25 namespace remoting {
26 26
27 namespace protocol { 27 namespace protocol {
28 class PairingRegistry; 28 class PairingRegistry;
29 } // namespace protocol 29 } // namespace protocol
30 30
31 // Implementation of the native messaging host process. 31 // Implementation of the me2me native messaging host.
32 class NativeMessagingHost : public NativeMessagingChannel::Delegate { 32 class NativeMessagingHost {
33 public: 33 public:
34 typedef NativeMessagingChannel::SendMessageCallback SendMessageCallback; 34 typedef NativeMessagingChannel::SendMessageCallback SendMessageCallback;
35 35
36 NativeMessagingHost( 36 NativeMessagingHost(
37 scoped_refptr<DaemonController> daemon_controller, 37 scoped_refptr<DaemonController> daemon_controller,
38 scoped_refptr<protocol::PairingRegistry> pairing_registry, 38 scoped_refptr<protocol::PairingRegistry> pairing_registry,
39 scoped_ptr<OAuthClient> oauth_client); 39 scoped_ptr<OAuthClient> oauth_client);
40 virtual ~NativeMessagingHost(); 40 virtual ~NativeMessagingHost();
41 41
42 // NativeMessagingChannel::Delegate interface. 42 void Start(
43 virtual void SetSendMessageCallback( 43 base::PlatformFile input,
44 const SendMessageCallback& send_message) OVERRIDE; 44 base::PlatformFile output,
45 virtual void ProcessMessage( 45 const base::Closure& quit_closure);
46 scoped_ptr<base::DictionaryValue> message) OVERRIDE; 46 void ShutDown();
47 47
48 private: 48 private:
49 void ProcessMessage(scoped_ptr<base::DictionaryValue> message);
50
49 // These "Process.." methods handle specific request types. The |response| 51 // These "Process.." methods handle specific request types. The |response|
50 // dictionary is pre-filled by ProcessMessage() with the parts of the 52 // dictionary is pre-filled by ProcessMessage() with the parts of the
51 // response already known ("id" and "type" fields). 53 // response already known ("id" and "type" fields).
52 bool ProcessHello( 54 bool ProcessHello(
53 const base::DictionaryValue& message, 55 const base::DictionaryValue& message,
54 scoped_ptr<base::DictionaryValue> response); 56 scoped_ptr<base::DictionaryValue> response);
55 bool ProcessClearPairedClients( 57 bool ProcessClearPairedClients(
56 const base::DictionaryValue& message, 58 const base::DictionaryValue& message,
57 scoped_ptr<base::DictionaryValue> response); 59 scoped_ptr<base::DictionaryValue> response);
58 bool ProcessDeletePairedClient( 60 bool ProcessDeletePairedClient(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 scoped_ptr<base::DictionaryValue> response, 109 scoped_ptr<base::DictionaryValue> response,
108 const DaemonController::UsageStatsConsent& consent); 110 const DaemonController::UsageStatsConsent& consent);
109 void SendAsyncResult(scoped_ptr<base::DictionaryValue> response, 111 void SendAsyncResult(scoped_ptr<base::DictionaryValue> response,
110 DaemonController::AsyncResult result); 112 DaemonController::AsyncResult result);
111 void SendBooleanResult(scoped_ptr<base::DictionaryValue> response, 113 void SendBooleanResult(scoped_ptr<base::DictionaryValue> response,
112 bool result); 114 bool result);
113 void SendCredentialsResponse(scoped_ptr<base::DictionaryValue> response, 115 void SendCredentialsResponse(scoped_ptr<base::DictionaryValue> response,
114 const std::string& user_email, 116 const std::string& user_email,
115 const std::string& refresh_token); 117 const std::string& refresh_token);
116 118
119 base::Closure quit_closure_;
120
121 scoped_ptr<NativeMessagingChannel> channel_;
117 scoped_refptr<DaemonController> daemon_controller_; 122 scoped_refptr<DaemonController> daemon_controller_;
118 123
119 // Used to load and update the paired clients for this host. 124 // Used to load and update the paired clients for this host.
120 scoped_refptr<protocol::PairingRegistry> pairing_registry_; 125 scoped_refptr<protocol::PairingRegistry> pairing_registry_;
121 126
122 // Used to exchange the service account authorization code for credentials. 127 // Used to exchange the service account authorization code for credentials.
123 scoped_ptr<OAuthClient> oauth_client_; 128 scoped_ptr<OAuthClient> oauth_client_;
124 129
125 base::ThreadChecker thread_checker_; 130 base::ThreadChecker thread_checker_;
126 131
127 SendMessageCallback send_message_;
128 base::WeakPtr<NativeMessagingHost> weak_ptr_; 132 base::WeakPtr<NativeMessagingHost> weak_ptr_;
129 base::WeakPtrFactory<NativeMessagingHost> weak_factory_; 133 base::WeakPtrFactory<NativeMessagingHost> weak_factory_;
130 134
131 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHost); 135 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHost);
132 }; 136 };
133 137
134 // Creates a NativeMessagingHost instance, attaches it to stdin/stdout and runs 138 // Creates a NativeMessagingHost instance, attaches it to stdin/stdout and runs
135 // the message loop until NativeMessagingHost signals shutdown. 139 // the message loop until NativeMessagingHost signals shutdown.
136 int NativeMessagingHostMain(); 140 int NativeMessagingHostMain();
137 141
138 } // namespace remoting 142 } // namespace remoting
139 143
140 #endif // REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_ 144 #endif // REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698