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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host.h

Issue 138833009: For C++ readability review. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/host/it2me/it2me_native_messaging_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ 5 #ifndef REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_
6 #define REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ 6 #define REMOTING_HOST_IT2ME_IT2ME_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"
11 #include "remoting/base/auto_thread_task_runner.h" 11 #include "remoting/base/auto_thread_task_runner.h"
12 #include "remoting/host/it2me/it2me_host.h" 12 #include "remoting/host/it2me/it2me_host.h"
13 #include "remoting/host/native_messaging/native_messaging_channel.h" 13 #include "remoting/host/native_messaging/native_messaging_channel.h"
14 14
15 namespace base { 15 namespace base {
16 class DictionaryValue; 16 class DictionaryValue;
17 } // namespace base 17 } // namespace base
18 18
19 namespace remoting { 19 namespace remoting {
20 20
21 // Implementation of the native messaging host process. 21 // Implementation of the native messaging host process.
22 class It2MeNativeMessagingHost : public It2MeHost::Observer { 22 class It2MeNativeMessagingHost : public It2MeHost::Observer {
23 public: 23 public:
24 typedef NativeMessagingChannel::SendMessageCallback SendMessageCallback;
25
26 It2MeNativeMessagingHost( 24 It2MeNativeMessagingHost(
27 scoped_refptr<AutoThreadTaskRunner> task_runner, 25 scoped_refptr<AutoThreadTaskRunner> task_runner,
28 scoped_ptr<NativeMessagingChannel> channel, 26 scoped_ptr<NativeMessagingChannel> channel,
29 scoped_ptr<It2MeHostFactory> factory); 27 scoped_ptr<It2MeHostFactory> factory);
30 virtual ~It2MeNativeMessagingHost(); 28 virtual ~It2MeNativeMessagingHost();
31 29
32 void Start(const base::Closure& quit_closure); 30 void Start(const base::Closure& quit_closure) const;
33 31
34 // It2MeHost::Observer implementation 32 // It2MeHost::Observer implementation
35 virtual void OnClientAuthenticated(const std::string& client_username) 33 virtual void OnClientAuthenticated(const std::string& client_username)
36 OVERRIDE; 34 OVERRIDE;
37 virtual void OnStoreAccessCode(const std::string& access_code, 35 virtual void OnStoreAccessCode(const std::string& access_code,
38 base::TimeDelta access_code_lifetime) OVERRIDE; 36 base::TimeDelta access_code_lifetime) OVERRIDE;
39 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) OVERRIDE; 37 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) OVERRIDE;
40 virtual void OnStateChanged(It2MeHostState state) OVERRIDE; 38 virtual void OnStateChanged(It2MeHostState state) OVERRIDE;
41 39
42 static std::string HostStateToString(It2MeHostState host_state); 40 static std::string HostStateToString(It2MeHostState host_state);
43 41
44 private: 42 private:
45 void ProcessMessage(scoped_ptr<base::DictionaryValue> message); 43 void ProcessMessage(scoped_ptr<base::DictionaryValue> message);
46 44
47 // These "Process.." methods handle specific request types. The |response| 45 // These "Process.." methods handle specific request types. The |response|
48 // dictionary is pre-filled by ProcessMessage() with the parts of the 46 // dictionary is pre-filled by ProcessMessage() with the parts of the
49 // response already known ("id" and "type" fields). 47 // response already known ("id" and "type" fields).
50 void ProcessHello(const base::DictionaryValue& message, 48 void ProcessHello(const base::DictionaryValue& message,
51 scoped_ptr<base::DictionaryValue> response); 49 scoped_ptr<base::DictionaryValue> response) const;
52 void ProcessConnect(const base::DictionaryValue& message, 50 void ProcessConnect(const base::DictionaryValue& message,
53 scoped_ptr<base::DictionaryValue> response); 51 scoped_ptr<base::DictionaryValue> response);
54 void ProcessDisconnect(const base::DictionaryValue& message, 52 void ProcessDisconnect(const base::DictionaryValue& message,
55 scoped_ptr<base::DictionaryValue> response); 53 scoped_ptr<base::DictionaryValue> response);
56 void SendErrorAndExit(scoped_ptr<base::DictionaryValue> response, 54 void SendErrorAndExit(scoped_ptr<base::DictionaryValue> response,
57 const std::string& description); 55 const std::string& description) const;
58 56
59 scoped_refptr<AutoThreadTaskRunner> task_runner(); 57 scoped_refptr<AutoThreadTaskRunner> task_runner() const;
60 58
61 scoped_ptr<NativeMessagingChannel> channel_; 59 scoped_ptr<NativeMessagingChannel> channel_;
62 scoped_ptr<It2MeHostFactory> factory_; 60 scoped_ptr<It2MeHostFactory> factory_;
63 scoped_ptr<ChromotingHostContext> host_context_; 61 scoped_ptr<ChromotingHostContext> host_context_;
64 scoped_refptr<It2MeHost> it2me_host_; 62 scoped_refptr<It2MeHost> it2me_host_;
65 63
66 // Cached, read-only copies of |it2me_host_| session state. 64 // Cached, read-only copies of |it2me_host_| session state.
67 It2MeHostState state_; 65 It2MeHostState state_;
68 std::string access_code_; 66 std::string access_code_;
69 base::TimeDelta access_code_lifetime_; 67 base::TimeDelta access_code_lifetime_;
70 std::string client_username_; 68 std::string client_username_;
71 69
72 // IT2Me Talk server configuration used by |it2me_host_| to connect. 70 // IT2Me Talk server configuration used by |it2me_host_| to connect.
73 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; 71 XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
74 72
75 // Chromoting Bot JID used by |it2me_host_| to register the host. 73 // Chromoting Bot JID used by |it2me_host_| to register the host.
76 std::string directory_bot_jid_; 74 std::string directory_bot_jid_;
77 75
78 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; 76 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_;
79 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; 77 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_;
80 78
81 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); 79 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost);
82 }; 80 };
83 81
84 } // namespace remoting 82 } // namespace remoting
85 83
86 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ 84 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_
85
nadav 2014/02/20 00:48:47 You should now be able to remove the trailing empt
OLDNEW
« no previous file with comments | « no previous file | remoting/host/it2me/it2me_native_messaging_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698