| 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/utility_process_host.h" | 5 #include "chrome/browser/utility_process_host.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 MessageLoop* message_loop_; | 65 MessageLoop* message_loop_; |
| 66 bool success_; | 66 bool success_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 class TestUtilityProcessHost : public UtilityProcessHost { | 69 class TestUtilityProcessHost : public UtilityProcessHost { |
| 70 public: | 70 public: |
| 71 TestUtilityProcessHost(TestUtilityProcessHostClient* client, | 71 TestUtilityProcessHost(TestUtilityProcessHostClient* client, |
| 72 MessageLoop* loop_io) | 72 MessageLoop* loop_io, |
| 73 : UtilityProcessHost(new ResourceDispatcherHost(NULL), client, loop_io) { | 73 ResourceDispatcherHost* rdh) |
| 74 : UtilityProcessHost(rdh, client, loop_io) { |
| 74 } | 75 } |
| 75 | 76 |
| 76 protected: | 77 protected: |
| 77 virtual std::wstring GetUtilityProcessCmd() { | 78 virtual std::wstring GetUtilityProcessCmd() { |
| 78 FilePath exe_path; | 79 FilePath exe_path; |
| 79 PathService::Get(base::DIR_EXE, &exe_path); | 80 PathService::Get(base::DIR_EXE, &exe_path); |
| 80 exe_path = exe_path.AppendASCII(WideToASCII( | 81 exe_path = exe_path.AppendASCII(WideToASCII( |
| 81 chrome::kBrowserProcessExecutablePath)); | 82 chrome::kBrowserProcessExecutablePath)); |
| 82 return exe_path.ToWStringHack(); | 83 return exe_path.ToWStringHack(); |
| 83 } | 84 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 .AppendASCII("theme.crx"); | 98 .AppendASCII("theme.crx"); |
| 98 FilePath temp_extension_dir; | 99 FilePath temp_extension_dir; |
| 99 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_extension_dir)); | 100 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_extension_dir)); |
| 100 temp_extension_dir = temp_extension_dir.AppendASCII("extension_test"); | 101 temp_extension_dir = temp_extension_dir.AppendASCII("extension_test"); |
| 101 ASSERT_TRUE(file_util::CreateDirectory(temp_extension_dir)); | 102 ASSERT_TRUE(file_util::CreateDirectory(temp_extension_dir)); |
| 102 ASSERT_TRUE(file_util::CopyFile(extension_file, | 103 ASSERT_TRUE(file_util::CopyFile(extension_file, |
| 103 temp_extension_dir.AppendASCII("theme.crx"))); | 104 temp_extension_dir.AppendASCII("theme.crx"))); |
| 104 | 105 |
| 105 scoped_refptr<TestUtilityProcessHostClient> client( | 106 scoped_refptr<TestUtilityProcessHostClient> client( |
| 106 new TestUtilityProcessHostClient(&message_loop_)); | 107 new TestUtilityProcessHostClient(&message_loop_)); |
| 107 TestUtilityProcessHost* process_host = new TestUtilityProcessHost( | 108 ResourceDispatcherHost rdh(NULL); |
| 108 client.get(), &message_loop_); | 109 TestUtilityProcessHost process_host(client.get(), &message_loop_, &rdh); |
| 109 process_host->StartExtensionUnpacker( | 110 process_host.StartExtensionUnpacker( |
| 110 temp_extension_dir.AppendASCII("theme.crx")); | 111 temp_extension_dir.AppendASCII("theme.crx")); |
| 111 message_loop_.Run(); | 112 message_loop_.Run(); |
| 112 EXPECT_TRUE(client->success()); | 113 EXPECT_TRUE(client->success()); |
| 113 | 114 |
| 114 // Clean up the temp dir. | 115 // Clean up the temp dir. |
| 115 file_util::Delete(temp_extension_dir, true); | 116 file_util::Delete(temp_extension_dir, true); |
| 116 } | 117 } |
| 117 | 118 |
| 118 } // namespace | 119 } // namespace |
| OLD | NEW |