OLD | NEW |
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 #include "remoting/host/it2me/it2me_native_messaging_host.h" | 5 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 base::WeakPtr<It2MeHost::Observer> observer, | 72 base::WeakPtr<It2MeHost::Observer> observer, |
73 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 73 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
74 const std::string& directory_bot_jid) | 74 const std::string& directory_bot_jid) |
75 : It2MeHost(context, | 75 : It2MeHost(context, |
76 task_runner, | 76 task_runner, |
77 observer, | 77 observer, |
78 xmpp_server_config, | 78 xmpp_server_config, |
79 directory_bot_jid) {} | 79 directory_bot_jid) {} |
80 | 80 |
81 // It2MeHost overrides | 81 // It2MeHost overrides |
82 virtual void Connect() override; | 82 void Connect() override; |
83 virtual void Disconnect() override; | 83 void Disconnect() override; |
84 virtual void RequestNatPolicy() override; | 84 void RequestNatPolicy() override; |
85 | 85 |
86 private: | 86 private: |
87 virtual ~MockIt2MeHost() {} | 87 ~MockIt2MeHost() override {} |
88 | 88 |
89 void RunSetState(It2MeHostState state); | 89 void RunSetState(It2MeHostState state); |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHost); | 91 DISALLOW_COPY_AND_ASSIGN(MockIt2MeHost); |
92 }; | 92 }; |
93 | 93 |
94 void MockIt2MeHost::Connect() { | 94 void MockIt2MeHost::Connect() { |
95 if (!host_context()->ui_task_runner()->BelongsToCurrentThread()) { | 95 if (!host_context()->ui_task_runner()->BelongsToCurrentThread()) { |
96 DCHECK(task_runner()->BelongsToCurrentThread()); | 96 DCHECK(task_runner()->BelongsToCurrentThread()); |
97 host_context()->ui_task_runner()->PostTask( | 97 host_context()->ui_task_runner()->PostTask( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 host_context()->network_task_runner()->PostTask( | 142 host_context()->network_task_runner()->PostTask( |
143 FROM_HERE, base::Bind(&It2MeHost::SetStateForTesting, this, state)); | 143 FROM_HERE, base::Bind(&It2MeHost::SetStateForTesting, this, state)); |
144 } else { | 144 } else { |
145 SetStateForTesting(state); | 145 SetStateForTesting(state); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 class MockIt2MeHostFactory : public It2MeHostFactory { | 149 class MockIt2MeHostFactory : public It2MeHostFactory { |
150 public: | 150 public: |
151 MockIt2MeHostFactory() {} | 151 MockIt2MeHostFactory() {} |
152 virtual scoped_refptr<It2MeHost> CreateIt2MeHost( | 152 scoped_refptr<It2MeHost> CreateIt2MeHost( |
153 ChromotingHostContext* context, | 153 ChromotingHostContext* context, |
154 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 154 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
155 base::WeakPtr<It2MeHost::Observer> observer, | 155 base::WeakPtr<It2MeHost::Observer> observer, |
156 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 156 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
157 const std::string& directory_bot_jid) override { | 157 const std::string& directory_bot_jid) override { |
158 return new MockIt2MeHost( | 158 return new MockIt2MeHost( |
159 context, task_runner, observer, xmpp_server_config, directory_bot_jid); | 159 context, task_runner, observer, xmpp_server_config, directory_bot_jid); |
160 } | 160 } |
161 | 161 |
162 private: | 162 private: |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 554 |
555 // Verify rejection if type is unrecognized. | 555 // Verify rejection if type is unrecognized. |
556 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { | 556 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { |
557 base::DictionaryValue message; | 557 base::DictionaryValue message; |
558 message.SetString("type", "xxx"); | 558 message.SetString("type", "xxx"); |
559 TestBadRequest(message, true); | 559 TestBadRequest(message, true); |
560 } | 560 } |
561 | 561 |
562 } // namespace remoting | 562 } // namespace remoting |
563 | 563 |
OLD | NEW |