| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 result_string = decrypted_text; | 93 result_string = decrypted_text; |
| 94 got_result = true; | 94 got_result = true; |
| 95 MessageLoop::current()->Quit(); | 95 MessageLoop::current()->Quit(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void QuitClient() { | 98 void QuitClient() { |
| 99 if (sender_) | 99 if (sender_) |
| 100 sender_->Send(new Msg_Decryptor_Quit()); | 100 sender_->Send(new Msg_Decryptor_Quit()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual bool OnMessageReceived(const IPC::Message& msg) { | 103 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { |
| 104 bool handled = true; | 104 bool handled = true; |
| 105 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg) | 105 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg) |
| 106 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse) | 106 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse) |
| 107 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResonse) | 107 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResonse) |
| 108 IPC_MESSAGE_UNHANDLED(handled = false) | 108 IPC_MESSAGE_UNHANDLED(handled = false) |
| 109 IPC_END_MESSAGE_MAP() | 109 IPC_END_MESSAGE_MAP() |
| 110 return handled; | 110 return handled; |
| 111 } | 111 } |
| 112 | 112 |
| 113 // If an error occured, just kill the message Loop. | 113 // If an error occured, just kill the message Loop. |
| 114 virtual void OnChannelError() { | 114 virtual void OnChannelError() OVERRIDE { |
| 115 got_result = false; | 115 got_result = false; |
| 116 MessageLoop::current()->Quit(); | 116 MessageLoop::current()->Quit(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Results of IPC calls. | 119 // Results of IPC calls. |
| 120 string16 result_string; | 120 string16 result_string; |
| 121 bool result_bool; | 121 bool result_bool; |
| 122 // True if IPC call succeeded and data in above variables is valid. | 122 // True if IPC call succeeded and data in above variables is valid. |
| 123 bool got_result; | 123 bool got_result; |
| 124 | 124 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 void OnDecrypt(std::string crypt) { | 238 void OnDecrypt(std::string crypt) { |
| 239 string16 unencrypted_str = decryptor_.Decrypt(crypt); | 239 string16 unencrypted_str = decryptor_.Decrypt(crypt); |
| 240 sender_->Send(new Msg_Decryptor_Response(unencrypted_str)); | 240 sender_->Send(new Msg_Decryptor_Response(unencrypted_str)); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void OnQuitRequest() { | 243 void OnQuitRequest() { |
| 244 MessageLoop::current()->Quit(); | 244 MessageLoop::current()->Quit(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 virtual bool OnMessageReceived(const IPC::Message& msg) { | 247 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { |
| 248 bool handled = true; | 248 bool handled = true; |
| 249 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg) | 249 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg) |
| 250 IPC_MESSAGE_HANDLER(Msg_Decryptor_Init, OnDecryptor_Init) | 250 IPC_MESSAGE_HANDLER(Msg_Decryptor_Init, OnDecryptor_Init) |
| 251 IPC_MESSAGE_HANDLER(Msg_Decrypt, OnDecrypt) | 251 IPC_MESSAGE_HANDLER(Msg_Decrypt, OnDecrypt) |
| 252 IPC_MESSAGE_HANDLER(Msg_Decryptor_Quit, OnQuitRequest) | 252 IPC_MESSAGE_HANDLER(Msg_Decryptor_Quit, OnQuitRequest) |
| 253 IPC_MESSAGE_UNHANDLED(handled = false) | 253 IPC_MESSAGE_UNHANDLED(handled = false) |
| 254 IPC_END_MESSAGE_MAP() | 254 IPC_END_MESSAGE_MAP() |
| 255 return handled; | 255 return handled; |
| 256 } | 256 } |
| 257 | 257 |
| 258 virtual void OnChannelError() { | 258 virtual void OnChannelError() OVERRIDE { |
| 259 MessageLoop::current()->Quit(); | 259 MessageLoop::current()->Quit(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 private: | 262 private: |
| 263 NSSDecryptor decryptor_; | 263 NSSDecryptor decryptor_; |
| 264 IPC::Sender* sender_; | 264 IPC::Sender* sender_; |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 // Entry function in child process. | 267 // Entry function in child process. |
| 268 MULTIPROCESS_IPC_TEST_MAIN(NSSDecrypterChildProcess) { | 268 MULTIPROCESS_IPC_TEST_MAIN(NSSDecrypterChildProcess) { |
| 269 MessageLoopForIO main_message_loop; | 269 MessageLoopForIO main_message_loop; |
| 270 FFDecryptorClientChannelListener listener; | 270 FFDecryptorClientChannelListener listener; |
| 271 | 271 |
| 272 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); | 272 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); |
| 273 CHECK(channel.Connect()); | 273 CHECK(channel.Connect()); |
| 274 listener.SetSender(&channel); | 274 listener.SetSender(&channel); |
| 275 | 275 |
| 276 // run message loop | 276 // run message loop |
| 277 MessageLoop::current()->Run(); | 277 MessageLoop::current()->Run(); |
| 278 | 278 |
| 279 return 0; | 279 return 0; |
| 280 } | 280 } |
| OLD | NEW |