OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ |
6 #define CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ | 6 #define CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
11 #include "chrome/browser/importer/nss_decryptor.h" | 11 #include "chrome/browser/importer/nss_decryptor.h" |
12 | 12 |
13 class FFDecryptorServerChannelListener; | 13 class FFDecryptorServerChannelListener; |
| 14 |
| 15 namespace base { |
| 16 class MessageLoopForIO; |
| 17 } |
| 18 |
14 namespace IPC { | 19 namespace IPC { |
15 class Channel; | 20 class Channel; |
16 } // namespace IPC | 21 } // namespace IPC |
17 class MessageLoopForIO; | |
18 | 22 |
19 // On OS X NSSDecryptor needs to run in a separate process. To allow us to use | 23 // On OS X NSSDecryptor needs to run in a separate process. To allow us to use |
20 // the same unit test on all platforms we use a proxy class which spawns a | 24 // the same unit test on all platforms we use a proxy class which spawns a |
21 // child process to do decryption on OS X, and calls through directly | 25 // child process to do decryption on OS X, and calls through directly |
22 // to NSSDecryptor on other platforms. | 26 // to NSSDecryptor on other platforms. |
23 // On OS X: | 27 // On OS X: |
24 // 2 IPC messages are sent for every method of NSSDecryptor, one containing the | 28 // 2 IPC messages are sent for every method of NSSDecryptor, one containing the |
25 // input arguments sent from Server->Child and one coming back containing | 29 // input arguments sent from Server->Child and one coming back containing |
26 // the return argument e.g. | 30 // the return argument e.g. |
27 // | 31 // |
(...skipping 17 matching lines...) Expand all Loading... |
45 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
46 // Blocks until either a timeout is reached, or until the client process | 50 // Blocks until either a timeout is reached, or until the client process |
47 // responds to an IPC message. | 51 // responds to an IPC message. |
48 // Returns true if a reply was received successfully and false if the | 52 // Returns true if a reply was received successfully and false if the |
49 // the operation timed out. | 53 // the operation timed out. |
50 bool WaitForClientResponse(); | 54 bool WaitForClientResponse(); |
51 | 55 |
52 base::ProcessHandle child_process_; | 56 base::ProcessHandle child_process_; |
53 scoped_ptr<IPC::Channel> channel_; | 57 scoped_ptr<IPC::Channel> channel_; |
54 scoped_ptr<FFDecryptorServerChannelListener> listener_; | 58 scoped_ptr<FFDecryptorServerChannelListener> listener_; |
55 scoped_ptr<MessageLoopForIO> message_loop_; | 59 scoped_ptr<base::MessageLoopForIO> message_loop_; |
56 #else | 60 #else |
57 NSSDecryptor decryptor_; | 61 NSSDecryptor decryptor_; |
58 #endif // !OS_MACOSX | 62 #endif // !OS_MACOSX |
59 DISALLOW_COPY_AND_ASSIGN(FFUnitTestDecryptorProxy); | 63 DISALLOW_COPY_AND_ASSIGN(FFUnitTestDecryptorProxy); |
60 }; | 64 }; |
61 | 65 |
62 // On Non-OSX platforms FFUnitTestDecryptorProxy simply calls through to | 66 // On Non-OSX platforms FFUnitTestDecryptorProxy simply calls through to |
63 // NSSDecryptor. | 67 // NSSDecryptor. |
64 #if !defined(OS_MACOSX) | 68 #if !defined(OS_MACOSX) |
65 FFUnitTestDecryptorProxy::FFUnitTestDecryptorProxy() { | 69 FFUnitTestDecryptorProxy::FFUnitTestDecryptorProxy() { |
(...skipping 10 matching lines...) Expand all Loading... |
76 const base::FilePath& db_path) { | 80 const base::FilePath& db_path) { |
77 return decryptor_.Init(dll_path, db_path); | 81 return decryptor_.Init(dll_path, db_path); |
78 } | 82 } |
79 | 83 |
80 string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) { | 84 string16 FFUnitTestDecryptorProxy::Decrypt(const std::string& crypt) { |
81 return decryptor_.Decrypt(crypt); | 85 return decryptor_.Decrypt(crypt); |
82 } | 86 } |
83 #endif // !OS_MACOSX | 87 #endif // !OS_MACOSX |
84 | 88 |
85 #endif // CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ | 89 #endif // CHROME_BROWSER_IMPORTER_FIREFOX_IMPORTER_UNITTEST_UTILS_H_ |
OLD | NEW |