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

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_ptr<NativeMessagingChannel> channel,
37 scoped_refptr<DaemonController> daemon_controller, 38 scoped_refptr<DaemonController> daemon_controller,
38 scoped_refptr<protocol::PairingRegistry> pairing_registry, 39 scoped_refptr<protocol::PairingRegistry> pairing_registry,
39 scoped_ptr<OAuthClient> oauth_client); 40 scoped_ptr<OAuthClient> oauth_client);
40 virtual ~NativeMessagingHost(); 41 virtual ~NativeMessagingHost();
41 42
42 // NativeMessagingChannel::Delegate interface. 43 void Start(const base::Closure& quit_closure);
43 virtual void SetSendMessageCallback(
44 const SendMessageCallback& send_message) OVERRIDE;
45 virtual void ProcessMessage(
46 scoped_ptr<base::DictionaryValue> message) OVERRIDE;
47 44
48 private: 45 private:
46 void ProcessMessage(scoped_ptr<base::DictionaryValue> message);
47
49 // These "Process.." methods handle specific request types. The |response| 48 // These "Process.." methods handle specific request types. The |response|
50 // dictionary is pre-filled by ProcessMessage() with the parts of the 49 // dictionary is pre-filled by ProcessMessage() with the parts of the
51 // response already known ("id" and "type" fields). 50 // response already known ("id" and "type" fields).
52 bool ProcessHello( 51 bool ProcessHello(
53 const base::DictionaryValue& message, 52 const base::DictionaryValue& message,
54 scoped_ptr<base::DictionaryValue> response); 53 scoped_ptr<base::DictionaryValue> response);
55 bool ProcessClearPairedClients( 54 bool ProcessClearPairedClients(
56 const base::DictionaryValue& message, 55 const base::DictionaryValue& message,
57 scoped_ptr<base::DictionaryValue> response); 56 scoped_ptr<base::DictionaryValue> response);
58 bool ProcessDeletePairedClient( 57 bool ProcessDeletePairedClient(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 scoped_ptr<base::DictionaryValue> response, 106 scoped_ptr<base::DictionaryValue> response,
108 const DaemonController::UsageStatsConsent& consent); 107 const DaemonController::UsageStatsConsent& consent);
109 void SendAsyncResult(scoped_ptr<base::DictionaryValue> response, 108 void SendAsyncResult(scoped_ptr<base::DictionaryValue> response,
110 DaemonController::AsyncResult result); 109 DaemonController::AsyncResult result);
111 void SendBooleanResult(scoped_ptr<base::DictionaryValue> response, 110 void SendBooleanResult(scoped_ptr<base::DictionaryValue> response,
112 bool result); 111 bool result);
113 void SendCredentialsResponse(scoped_ptr<base::DictionaryValue> response, 112 void SendCredentialsResponse(scoped_ptr<base::DictionaryValue> response,
114 const std::string& user_email, 113 const std::string& user_email,
115 const std::string& refresh_token); 114 const std::string& refresh_token);
116 115
116 scoped_ptr<NativeMessagingChannel> channel_;
117 scoped_refptr<DaemonController> daemon_controller_; 117 scoped_refptr<DaemonController> daemon_controller_;
118 118
119 // Used to load and update the paired clients for this host. 119 // Used to load and update the paired clients for this host.
120 scoped_refptr<protocol::PairingRegistry> pairing_registry_; 120 scoped_refptr<protocol::PairingRegistry> pairing_registry_;
121 121
122 // Used to exchange the service account authorization code for credentials. 122 // Used to exchange the service account authorization code for credentials.
123 scoped_ptr<OAuthClient> oauth_client_; 123 scoped_ptr<OAuthClient> oauth_client_;
124 124
125 base::ThreadChecker thread_checker_; 125 base::ThreadChecker thread_checker_;
126 126
127 SendMessageCallback send_message_;
128 base::WeakPtr<NativeMessagingHost> weak_ptr_; 127 base::WeakPtr<NativeMessagingHost> weak_ptr_;
129 base::WeakPtrFactory<NativeMessagingHost> weak_factory_; 128 base::WeakPtrFactory<NativeMessagingHost> weak_factory_;
130 129
131 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHost); 130 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHost);
132 }; 131 };
133 132
134 // Creates a NativeMessagingHost instance, attaches it to stdin/stdout and runs 133 // Creates a NativeMessagingHost instance, attaches it to stdin/stdout and runs
135 // the message loop until NativeMessagingHost signals shutdown. 134 // the message loop until NativeMessagingHost signals shutdown.
136 int NativeMessagingHostMain(); 135 int NativeMessagingHostMain();
137 136
138 } // namespace remoting 137 } // namespace remoting
139 138
140 #endif // REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_ 139 #endif // REMOTING_HOST_SETUP_ME2ME_NATIVE_MESSAGING_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698