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

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

Issue 558403002: Remote Assistance on Chrome OS Part II - Native Messaging renaming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows host Created 6 years, 3 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 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 "extensions/browser/api/messaging/native_messaging_channel.h"
11 #include "remoting/base/auto_thread_task_runner.h" 12 #include "remoting/base/auto_thread_task_runner.h"
12 #include "remoting/host/it2me/it2me_host.h" 13 #include "remoting/host/it2me/it2me_host.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
23 : public It2MeHost::Observer,
24 public extensions::NativeMessagingChannel::EventHandler {
23 public: 25 public:
24 It2MeNativeMessagingHost( 26 It2MeNativeMessagingHost(
25 scoped_refptr<AutoThreadTaskRunner> task_runner, 27 scoped_refptr<AutoThreadTaskRunner> task_runner,
26 scoped_ptr<NativeMessagingChannel> channel, 28 scoped_ptr<extensions::NativeMessagingChannel> channel,
27 scoped_ptr<It2MeHostFactory> factory); 29 scoped_ptr<It2MeHostFactory> factory);
28 virtual ~It2MeNativeMessagingHost(); 30 virtual ~It2MeNativeMessagingHost();
29 31
30 void Start(const base::Closure& quit_closure) const; 32 void Start(const base::Closure& quit_closure);
33
34 // extensions::NativeMessagingChannel::EventHandler implementation
Sergey Ulanov 2014/09/18 18:08:35 nit: add . at the end of the comment
kelvinp 2014/09/18 19:03:50 Done.
35 virtual void OnMessage(scoped_ptr<base::Value> message) OVERRIDE;
36 virtual void OnDisconnect() OVERRIDE;
31 37
32 // It2MeHost::Observer implementation 38 // It2MeHost::Observer implementation
33 virtual void OnClientAuthenticated(const std::string& client_username) 39 virtual void OnClientAuthenticated(const std::string& client_username)
34 OVERRIDE; 40 OVERRIDE;
35 virtual void OnStoreAccessCode(const std::string& access_code, 41 virtual void OnStoreAccessCode(const std::string& access_code,
36 base::TimeDelta access_code_lifetime) OVERRIDE; 42 base::TimeDelta access_code_lifetime) OVERRIDE;
37 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) OVERRIDE; 43 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) OVERRIDE;
38 virtual void OnStateChanged(It2MeHostState state) OVERRIDE; 44 virtual void OnStateChanged(It2MeHostState state) OVERRIDE;
39 45
40 static std::string HostStateToString(It2MeHostState host_state); 46 static std::string HostStateToString(It2MeHostState host_state);
41 47
42 private: 48 private:
43 void ProcessMessage(scoped_ptr<base::DictionaryValue> message);
44
45 // These "Process.." methods handle specific request types. The |response| 49 // These "Process.." methods handle specific request types. The |response|
46 // dictionary is pre-filled by ProcessMessage() with the parts of the 50 // dictionary is pre-filled by ProcessMessage() with the parts of the
47 // response already known ("id" and "type" fields). 51 // response already known ("id" and "type" fields).
48 void ProcessHello(const base::DictionaryValue& message, 52 void ProcessHello(const base::DictionaryValue& message,
49 scoped_ptr<base::DictionaryValue> response) const; 53 scoped_ptr<base::DictionaryValue> response) const;
50 void ProcessConnect(const base::DictionaryValue& message, 54 void ProcessConnect(const base::DictionaryValue& message,
51 scoped_ptr<base::DictionaryValue> response); 55 scoped_ptr<base::DictionaryValue> response);
52 void ProcessDisconnect(const base::DictionaryValue& message, 56 void ProcessDisconnect(const base::DictionaryValue& message,
53 scoped_ptr<base::DictionaryValue> response); 57 scoped_ptr<base::DictionaryValue> response);
54 void SendErrorAndExit(scoped_ptr<base::DictionaryValue> response, 58 void SendErrorAndExit(scoped_ptr<base::DictionaryValue> response,
55 const std::string& description) const; 59 const std::string& description) const;
56 60
61 base::Closure quit_closure_;
62
57 scoped_refptr<AutoThreadTaskRunner> task_runner() const; 63 scoped_refptr<AutoThreadTaskRunner> task_runner() const;
58 64
59 scoped_ptr<NativeMessagingChannel> channel_; 65 scoped_ptr<extensions::NativeMessagingChannel> channel_;
60 scoped_ptr<It2MeHostFactory> factory_; 66 scoped_ptr<It2MeHostFactory> factory_;
61 scoped_ptr<ChromotingHostContext> host_context_; 67 scoped_ptr<ChromotingHostContext> host_context_;
62 scoped_refptr<It2MeHost> it2me_host_; 68 scoped_refptr<It2MeHost> it2me_host_;
63 69
64 // Cached, read-only copies of |it2me_host_| session state. 70 // Cached, read-only copies of |it2me_host_| session state.
65 It2MeHostState state_; 71 It2MeHostState state_;
66 std::string access_code_; 72 std::string access_code_;
67 base::TimeDelta access_code_lifetime_; 73 base::TimeDelta access_code_lifetime_;
68 std::string client_username_; 74 std::string client_username_;
69 75
70 // IT2Me Talk server configuration used by |it2me_host_| to connect. 76 // IT2Me Talk server configuration used by |it2me_host_| to connect.
71 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; 77 XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
72 78
73 // Chromoting Bot JID used by |it2me_host_| to register the host. 79 // Chromoting Bot JID used by |it2me_host_| to register the host.
74 std::string directory_bot_jid_; 80 std::string directory_bot_jid_;
75 81
76 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; 82 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_;
77 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; 83 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_;
78 84
79 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); 85 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost);
80 }; 86 };
81 87
82 } // namespace remoting 88 } // namespace remoting
83 89
84 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ 90 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_
85 91
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698