| 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/utility/importer/firefox_importer_unittest_utils.h" | 5 #include "chrome/utility/importer/firefox_importer_unittest_utils.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 result_vector = parsed_vector; | 96 result_vector = parsed_vector; |
| 97 got_result = true; | 97 got_result = true; |
| 98 base::MessageLoop::current()->Quit(); | 98 base::MessageLoop::current()->Quit(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void QuitClient() { | 101 void QuitClient() { |
| 102 if (sender_) | 102 if (sender_) |
| 103 sender_->Send(new Msg_Decryptor_Quit()); | 103 sender_->Send(new Msg_Decryptor_Quit()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { | 106 virtual bool OnMessageReceived(const IPC::Message& msg) override { |
| 107 bool handled = true; | 107 bool handled = true; |
| 108 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg) | 108 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg) |
| 109 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse) | 109 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse) |
| 110 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResponse) | 110 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResponse) |
| 111 IPC_MESSAGE_HANDLER(Msg_ParseSignons_Response, OnParseSignonsResponse) | 111 IPC_MESSAGE_HANDLER(Msg_ParseSignons_Response, OnParseSignonsResponse) |
| 112 IPC_MESSAGE_UNHANDLED(handled = false) | 112 IPC_MESSAGE_UNHANDLED(handled = false) |
| 113 IPC_END_MESSAGE_MAP() | 113 IPC_END_MESSAGE_MAP() |
| 114 return handled; | 114 return handled; |
| 115 } | 115 } |
| 116 | 116 |
| 117 // If an error occured, just kill the message Loop. | 117 // If an error occured, just kill the message Loop. |
| 118 virtual void OnChannelError() OVERRIDE { | 118 virtual void OnChannelError() override { |
| 119 got_result = false; | 119 got_result = false; |
| 120 base::MessageLoop::current()->Quit(); | 120 base::MessageLoop::current()->Quit(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Results of IPC calls. | 123 // Results of IPC calls. |
| 124 base::string16 result_string; | 124 base::string16 result_string; |
| 125 std::vector<autofill::PasswordForm> result_vector; | 125 std::vector<autofill::PasswordForm> result_vector; |
| 126 bool result_bool; | 126 bool result_bool; |
| 127 // True if IPC call succeeded and data in above variables is valid. | 127 // True if IPC call succeeded and data in above variables is valid. |
| 128 bool got_result; | 128 bool got_result; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void OnParseSignons(base::FilePath signons_path) { | 257 void OnParseSignons(base::FilePath signons_path) { |
| 258 std::vector<autofill::PasswordForm> forms; | 258 std::vector<autofill::PasswordForm> forms; |
| 259 decryptor_.ReadAndParseSignons(signons_path, &forms); | 259 decryptor_.ReadAndParseSignons(signons_path, &forms); |
| 260 sender_->Send(new Msg_ParseSignons_Response(forms)); | 260 sender_->Send(new Msg_ParseSignons_Response(forms)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void OnQuitRequest() { | 263 void OnQuitRequest() { |
| 264 base::MessageLoop::current()->Quit(); | 264 base::MessageLoop::current()->Quit(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { | 267 virtual bool OnMessageReceived(const IPC::Message& msg) override { |
| 268 bool handled = true; | 268 bool handled = true; |
| 269 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg) | 269 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg) |
| 270 IPC_MESSAGE_HANDLER(Msg_Decryptor_Init, OnDecryptor_Init) | 270 IPC_MESSAGE_HANDLER(Msg_Decryptor_Init, OnDecryptor_Init) |
| 271 IPC_MESSAGE_HANDLER(Msg_Decrypt, OnDecrypt) | 271 IPC_MESSAGE_HANDLER(Msg_Decrypt, OnDecrypt) |
| 272 IPC_MESSAGE_HANDLER(Msg_ParseSignons, OnParseSignons) | 272 IPC_MESSAGE_HANDLER(Msg_ParseSignons, OnParseSignons) |
| 273 IPC_MESSAGE_HANDLER(Msg_Decryptor_Quit, OnQuitRequest) | 273 IPC_MESSAGE_HANDLER(Msg_Decryptor_Quit, OnQuitRequest) |
| 274 IPC_MESSAGE_UNHANDLED(handled = false) | 274 IPC_MESSAGE_UNHANDLED(handled = false) |
| 275 IPC_END_MESSAGE_MAP() | 275 IPC_END_MESSAGE_MAP() |
| 276 return handled; | 276 return handled; |
| 277 } | 277 } |
| 278 | 278 |
| 279 virtual void OnChannelError() OVERRIDE { | 279 virtual void OnChannelError() override { |
| 280 base::MessageLoop::current()->Quit(); | 280 base::MessageLoop::current()->Quit(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 private: | 283 private: |
| 284 NSSDecryptor decryptor_; | 284 NSSDecryptor decryptor_; |
| 285 IPC::Sender* sender_; | 285 IPC::Sender* sender_; |
| 286 }; | 286 }; |
| 287 | 287 |
| 288 // Entry function in child process. | 288 // Entry function in child process. |
| 289 MULTIPROCESS_IPC_TEST_MAIN(NSSDecrypterChildProcess) { | 289 MULTIPROCESS_IPC_TEST_MAIN(NSSDecrypterChildProcess) { |
| 290 base::MessageLoopForIO main_message_loop; | 290 base::MessageLoopForIO main_message_loop; |
| 291 FFDecryptorClientChannelListener listener; | 291 FFDecryptorClientChannelListener listener; |
| 292 | 292 |
| 293 scoped_ptr<IPC::Channel> channel = IPC::Channel::CreateClient( | 293 scoped_ptr<IPC::Channel> channel = IPC::Channel::CreateClient( |
| 294 kTestChannelID, &listener); | 294 kTestChannelID, &listener); |
| 295 CHECK(channel->Connect()); | 295 CHECK(channel->Connect()); |
| 296 listener.SetSender(channel.get()); | 296 listener.SetSender(channel.get()); |
| 297 | 297 |
| 298 // run message loop | 298 // run message loop |
| 299 base::MessageLoop::current()->Run(); | 299 base::MessageLoop::current()->Run(); |
| 300 | 300 |
| 301 return 0; | 301 return 0; |
| 302 } | 302 } |
| OLD | NEW |