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

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

Issue 639233002: Remote assistance on Chrome OS Part IV - It2MeHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error on ozone Created 6 years, 1 month 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
« no previous file with comments | « remoting/host/it2me/it2me_host.cc ('k') | 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 "extensions/browser/api/messaging/native_message_host.h" 11 #include "extensions/browser/api/messaging/native_message_host.h"
12 #include "remoting/base/auto_thread_task_runner.h" 12 #include "remoting/base/auto_thread_task_runner.h"
13 #include "remoting/host/chromoting_host_context.h"
13 #include "remoting/host/it2me/it2me_host.h" 14 #include "remoting/host/it2me/it2me_host.h"
14 15
15 namespace base { 16 namespace base {
16 class DictionaryValue; 17 class DictionaryValue;
17 class Value; 18 class Value;
18 } // namespace base 19 } // namespace base
19 20
20 namespace remoting { 21 namespace remoting {
21 22
22 // Implementation of the native messaging host process. 23 // Implementation of the native messaging host process.
23 class It2MeNativeMessagingHost : public It2MeHost::Observer, 24 class It2MeNativeMessagingHost : public It2MeHost::Observer,
24 public extensions::NativeMessageHost { 25 public extensions::NativeMessageHost {
25 public: 26 public:
26 It2MeNativeMessagingHost(scoped_refptr<AutoThreadTaskRunner> task_runner, 27 It2MeNativeMessagingHost(
27 scoped_ptr<It2MeHostFactory> factory); 28 scoped_ptr<ChromotingHostContext> host_context,
28 ~It2MeNativeMessagingHost() override; 29 scoped_ptr<It2MeHostFactory> host_factory);
30 ~It2MeNativeMessagingHost();
29 31
30 // extensions::NativeMessageHost implementation. 32 // extensions::NativeMessageHost implementation.
31 void OnMessage(const std::string& message) override; 33 void OnMessage(const std::string& message) override;
32 void Start(Client* client) override; 34 void Start(Client* client) override;
33 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override; 35 scoped_refptr<base::SingleThreadTaskRunner> task_runner()
36 const override;
34 37
35 // It2MeHost::Observer implementation. 38 // It2MeHost::Observer implementation.
36 void OnClientAuthenticated(const std::string& client_username) override; 39 void OnClientAuthenticated(const std::string& client_username)
40 override;
37 void OnStoreAccessCode(const std::string& access_code, 41 void OnStoreAccessCode(const std::string& access_code,
38 base::TimeDelta access_code_lifetime) override; 42 base::TimeDelta access_code_lifetime) override;
39 void OnNatPolicyChanged(bool nat_traversal_enabled) override; 43 void OnNatPolicyChanged(bool nat_traversal_enabled) override;
40 void OnStateChanged(It2MeHostState state) override; 44 void OnStateChanged(It2MeHostState state) override;
41 45
42 static std::string HostStateToString(It2MeHostState host_state); 46 static std::string HostStateToString(It2MeHostState host_state);
43 47
44 private: 48 private:
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 void SendMessageToClient(scoped_ptr<base::DictionaryValue> message) const; 60 void SendMessageToClient(scoped_ptr<base::DictionaryValue> message) const;
57 61
58 Client* client_; 62 Client* client_;
63 scoped_ptr<ChromotingHostContext> host_context_;
59 scoped_ptr<It2MeHostFactory> factory_; 64 scoped_ptr<It2MeHostFactory> factory_;
60 scoped_ptr<ChromotingHostContext> host_context_;
61 scoped_refptr<It2MeHost> it2me_host_; 65 scoped_refptr<It2MeHost> it2me_host_;
62 66
63 // Cached, read-only copies of |it2me_host_| session state. 67 // Cached, read-only copies of |it2me_host_| session state.
64 It2MeHostState state_; 68 It2MeHostState state_;
65 std::string access_code_; 69 std::string access_code_;
66 base::TimeDelta access_code_lifetime_; 70 base::TimeDelta access_code_lifetime_;
67 std::string client_username_; 71 std::string client_username_;
68 72
69 // IT2Me Talk server configuration used by |it2me_host_| to connect. 73 // IT2Me Talk server configuration used by |it2me_host_| to connect.
70 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; 74 XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
71 75
72 // Chromoting Bot JID used by |it2me_host_| to register the host. 76 // Chromoting Bot JID used by |it2me_host_| to register the host.
73 std::string directory_bot_jid_; 77 std::string directory_bot_jid_;
74 78
75 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_; 79 base::WeakPtr<It2MeNativeMessagingHost> weak_ptr_;
76 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_; 80 base::WeakPtrFactory<It2MeNativeMessagingHost> weak_factory_;
77 81
78 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost); 82 DISALLOW_COPY_AND_ASSIGN(It2MeNativeMessagingHost);
79 }; 83 };
80 84
81 } // namespace remoting 85 } // namespace remoting
82 86
83 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_ 87 #endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_H_
84 88
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_host.cc ('k') | remoting/host/it2me/it2me_native_messaging_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698