OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/importer/firefox_importer_unittest_utils.h" | 5 #include "chrome/browser/importer/firefox_importer_unittest_utils.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug_on_start.h" | 9 #include "base/debug_on_start.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 result_string = decrypted_text; | 87 result_string = decrypted_text; |
88 got_result = true; | 88 got_result = true; |
89 MessageLoop::current()->Quit(); | 89 MessageLoop::current()->Quit(); |
90 } | 90 } |
91 | 91 |
92 void QuitClient() { | 92 void QuitClient() { |
93 if (sender_) | 93 if (sender_) |
94 sender_->Send(new Msg_Decryptor_Quit()); | 94 sender_->Send(new Msg_Decryptor_Quit()); |
95 } | 95 } |
96 | 96 |
97 virtual void OnMessageReceived(const IPC::Message& msg) { | 97 virtual bool OnMessageReceived(const IPC::Message& msg) { |
| 98 bool handled = true; |
98 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg) | 99 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg) |
99 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse) | 100 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse) |
100 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResonse) | 101 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResonse) |
| 102 IPC_MESSAGE_UNHANDLED(handled = false) |
101 IPC_END_MESSAGE_MAP() | 103 IPC_END_MESSAGE_MAP() |
| 104 return handled; |
102 } | 105 } |
103 | 106 |
104 // If an error occured, just kill the message Loop. | 107 // If an error occured, just kill the message Loop. |
105 virtual void OnChannelError() { | 108 virtual void OnChannelError() { |
106 got_result = false; | 109 got_result = false; |
107 MessageLoop::current()->Quit(); | 110 MessageLoop::current()->Quit(); |
108 } | 111 } |
109 | 112 |
110 // Results of IPC calls. | 113 // Results of IPC calls. |
111 string16 result_string; | 114 string16 result_string; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 227 |
225 void OnDecrypt(std::string crypt) { | 228 void OnDecrypt(std::string crypt) { |
226 string16 unencrypted_str = decryptor_.Decrypt(crypt); | 229 string16 unencrypted_str = decryptor_.Decrypt(crypt); |
227 sender_->Send(new Msg_Decryptor_Response(unencrypted_str)); | 230 sender_->Send(new Msg_Decryptor_Response(unencrypted_str)); |
228 } | 231 } |
229 | 232 |
230 void OnQuitRequest() { | 233 void OnQuitRequest() { |
231 MessageLoop::current()->Quit(); | 234 MessageLoop::current()->Quit(); |
232 } | 235 } |
233 | 236 |
234 virtual void OnMessageReceived(const IPC::Message& msg) { | 237 virtual bool OnMessageReceived(const IPC::Message& msg) { |
| 238 bool handled = true; |
235 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg) | 239 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg) |
236 IPC_MESSAGE_HANDLER(Msg_Decryptor_Init, OnDecryptor_Init) | 240 IPC_MESSAGE_HANDLER(Msg_Decryptor_Init, OnDecryptor_Init) |
237 IPC_MESSAGE_HANDLER(Msg_Decrypt, OnDecrypt) | 241 IPC_MESSAGE_HANDLER(Msg_Decrypt, OnDecrypt) |
238 IPC_MESSAGE_HANDLER(Msg_Decryptor_Quit, OnQuitRequest) | 242 IPC_MESSAGE_HANDLER(Msg_Decryptor_Quit, OnQuitRequest) |
| 243 IPC_MESSAGE_UNHANDLED(handled = false) |
239 IPC_END_MESSAGE_MAP() | 244 IPC_END_MESSAGE_MAP() |
| 245 return handled; |
240 } | 246 } |
241 | 247 |
242 virtual void OnChannelError() { | 248 virtual void OnChannelError() { |
243 MessageLoop::current()->Quit(); | 249 MessageLoop::current()->Quit(); |
244 } | 250 } |
245 | 251 |
246 private: | 252 private: |
247 NSSDecryptor decryptor_; | 253 NSSDecryptor decryptor_; |
248 IPC::Message::Sender* sender_; | 254 IPC::Message::Sender* sender_; |
249 }; | 255 }; |
250 | 256 |
251 // Entry function in child process. | 257 // Entry function in child process. |
252 MULTIPROCESS_TEST_MAIN(NSSDecrypterChildProcess) { | 258 MULTIPROCESS_TEST_MAIN(NSSDecrypterChildProcess) { |
253 MessageLoopForIO main_message_loop; | 259 MessageLoopForIO main_message_loop; |
254 FFDecryptorClientChannelListener listener; | 260 FFDecryptorClientChannelListener listener; |
255 | 261 |
256 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); | 262 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); |
257 CHECK(channel.Connect()); | 263 CHECK(channel.Connect()); |
258 listener.SetSender(&channel); | 264 listener.SetSender(&channel); |
259 | 265 |
260 // run message loop | 266 // run message loop |
261 MessageLoop::current()->Run(); | 267 MessageLoop::current()->Run(); |
262 | 268 |
263 return 0; | 269 return 0; |
264 } | 270 } |
OLD | NEW |