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

Side by Side Diff: chrome/utility/importer/firefox_importer_unittest_utils_mac.cc

Issue 94013004: Add base:: to string16s in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 7 years 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 | Annotate | Revision Log
OLDNEW
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/file_util.h" 10 #include "base/file_util.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 sender_ = sender; 80 sender_ = sender;
81 } 81 }
82 82
83 void OnInitDecryptorResponse(bool result) { 83 void OnInitDecryptorResponse(bool result) {
84 DCHECK(!got_result); 84 DCHECK(!got_result);
85 result_bool = result; 85 result_bool = result;
86 got_result = true; 86 got_result = true;
87 base::MessageLoop::current()->Quit(); 87 base::MessageLoop::current()->Quit();
88 } 88 }
89 89
90 void OnDecryptedTextResonse(const string16& decrypted_text) { 90 void OnDecryptedTextResonse(const base::string16& decrypted_text) {
91 DCHECK(!got_result); 91 DCHECK(!got_result);
92 result_string = decrypted_text; 92 result_string = decrypted_text;
93 got_result = true; 93 got_result = true;
94 base::MessageLoop::current()->Quit(); 94 base::MessageLoop::current()->Quit();
95 } 95 }
96 96
97 void QuitClient() { 97 void QuitClient() {
98 if (sender_) 98 if (sender_)
99 sender_->Send(new Msg_Decryptor_Quit()); 99 sender_->Send(new Msg_Decryptor_Quit());
100 } 100 }
101 101
102 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { 102 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE {
103 bool handled = true; 103 bool handled = true;
104 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg) 104 IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg)
105 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse) 105 IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse)
106 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResonse) 106 IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResonse)
107 IPC_MESSAGE_UNHANDLED(handled = false) 107 IPC_MESSAGE_UNHANDLED(handled = false)
108 IPC_END_MESSAGE_MAP() 108 IPC_END_MESSAGE_MAP()
109 return handled; 109 return handled;
110 } 110 }
111 111
112 // If an error occured, just kill the message Loop. 112 // If an error occured, just kill the message Loop.
113 virtual void OnChannelError() OVERRIDE { 113 virtual void OnChannelError() OVERRIDE {
114 got_result = false; 114 got_result = false;
115 base::MessageLoop::current()->Quit(); 115 base::MessageLoop::current()->Quit();
116 } 116 }
117 117
118 // Results of IPC calls. 118 // Results of IPC calls.
119 string16 result_string; 119 base::string16 result_string;
120 bool result_bool; 120 bool result_bool;
121 // True if IPC call succeeded and data in above variables is valid. 121 // True if IPC call succeeded and data in above variables is valid.
122 bool got_result; 122 bool got_result;
123 123
124 private: 124 private:
125 IPC::Sender* sender_; // weak 125 IPC::Sender* sender_; // weak
126 }; 126 };
127 127
128 FFUnitTestDecryptorProxy::FFUnitTestDecryptorProxy() 128 FFUnitTestDecryptorProxy::FFUnitTestDecryptorProxy()
129 : child_process_(0) { 129 : child_process_(0) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 const base::FilePath& db_path) { 199 const base::FilePath& db_path) {
200 channel_->Send(new Msg_Decryptor_Init(dll_path, db_path)); 200 channel_->Send(new Msg_Decryptor_Init(dll_path, db_path));
201 bool ok = WaitForClientResponse(); 201 bool ok = WaitForClientResponse();
202 if (ok && listener_->got_result) { 202 if (ok && listener_->got_result) {
203 listener_->got_result = false; 203 listener_->got_result = false;
204 return listener_->result_bool; 204 return listener_->result_bool;
205 } 205 }
206 return false; 206 return false;
207 } 207 }
208 208
209 string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) { 209 base::string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) {
210 channel_->Send(new Msg_Decrypt(crypt)); 210 channel_->Send(new Msg_Decrypt(crypt));
211 bool ok = WaitForClientResponse(); 211 bool ok = WaitForClientResponse();
212 if (ok && listener_->got_result) { 212 if (ok && listener_->got_result) {
213 listener_->got_result = false; 213 listener_->got_result = false;
214 return listener_->result_string; 214 return listener_->result_string;
215 } 215 }
216 return string16(); 216 return base::string16();
217 } 217 }
218 218
219 //---------------------------- Child Process ----------------------- 219 //---------------------------- Child Process -----------------------
220 220
221 // Class to listen on the client side of the ipc channel, it calls through 221 // Class to listen on the client side of the ipc channel, it calls through
222 // to the NSSDecryptor and sends back a reply. 222 // to the NSSDecryptor and sends back a reply.
223 class FFDecryptorClientChannelListener : public IPC::Listener { 223 class FFDecryptorClientChannelListener : public IPC::Listener {
224 public: 224 public:
225 FFDecryptorClientChannelListener() 225 FFDecryptorClientChannelListener()
226 : sender_(NULL) {} 226 : sender_(NULL) {}
227 227
228 void SetSender(IPC::Sender* sender) { 228 void SetSender(IPC::Sender* sender) {
229 sender_ = sender; 229 sender_ = sender;
230 } 230 }
231 231
232 void OnDecryptor_Init(base::FilePath dll_path, base::FilePath db_path) { 232 void OnDecryptor_Init(base::FilePath dll_path, base::FilePath db_path) {
233 bool ret = decryptor_.Init(dll_path, db_path); 233 bool ret = decryptor_.Init(dll_path, db_path);
234 sender_->Send(new Msg_Decryptor_InitReturnCode(ret)); 234 sender_->Send(new Msg_Decryptor_InitReturnCode(ret));
235 } 235 }
236 236
237 void OnDecrypt(std::string crypt) { 237 void OnDecrypt(std::string crypt) {
238 string16 unencrypted_str = decryptor_.Decrypt(crypt); 238 base::string16 unencrypted_str = decryptor_.Decrypt(crypt);
239 sender_->Send(new Msg_Decryptor_Response(unencrypted_str)); 239 sender_->Send(new Msg_Decryptor_Response(unencrypted_str));
240 } 240 }
241 241
242 void OnQuitRequest() { 242 void OnQuitRequest() {
243 base::MessageLoop::current()->Quit(); 243 base::MessageLoop::current()->Quit();
244 } 244 }
245 245
246 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { 246 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE {
247 bool handled = true; 247 bool handled = true;
248 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg) 248 IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg)
(...skipping 21 matching lines...) Expand all
270 270
271 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); 271 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener);
272 CHECK(channel.Connect()); 272 CHECK(channel.Connect());
273 listener.SetSender(&channel); 273 listener.SetSender(&channel);
274 274
275 // run message loop 275 // run message loop
276 base::MessageLoop::current()->Run(); 276 base::MessageLoop::current()->Run();
277 277
278 return 0; 278 return 0;
279 } 279 }
OLDNEW
« no previous file with comments | « chrome/utility/importer/firefox_importer_unittest_utils.h ('k') | chrome/utility/importer/ie_importer_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698