| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return std::string(const_cast<const Pickle*>(&pickle)->payload(), | 140 return std::string(const_cast<const Pickle*>(&pickle)->payload(), |
| 141 pickle.payload_size()); | 141 pickle.payload_size()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 base::FilePath CreateTempFileWithMessage(const std::string& message) { | 144 base::FilePath CreateTempFileWithMessage(const std::string& message) { |
| 145 base::FilePath filename; | 145 base::FilePath filename; |
| 146 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &filename)) | 146 if (!base::CreateTemporaryFileInDir(temp_dir_.path(), &filename)) |
| 147 return base::FilePath(); | 147 return base::FilePath(); |
| 148 | 148 |
| 149 std::string message_with_header = FormatMessage(message); | 149 std::string message_with_header = FormatMessage(message); |
| 150 int bytes_written = file_util::WriteFile( | 150 int bytes_written = base::WriteFile( |
| 151 filename, message_with_header.data(), message_with_header.size()); | 151 filename, message_with_header.data(), message_with_header.size()); |
| 152 if (bytes_written < 0 || | 152 if (bytes_written < 0 || |
| 153 (message_with_header.size() != static_cast<size_t>(bytes_written))) { | 153 (message_with_header.size() != static_cast<size_t>(bytes_written))) { |
| 154 return base::FilePath(); | 154 return base::FilePath(); |
| 155 } | 155 } |
| 156 return filename; | 156 return filename; |
| 157 } | 157 } |
| 158 | 158 |
| 159 base::ScopedTempDir temp_dir_; | 159 base::ScopedTempDir temp_dir_; |
| 160 // Force the channel to be dev. | 160 // Force the channel to be dev. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 ScopedTestNativeMessagingHost::kHostName, 0, false); | 308 ScopedTestNativeMessagingHost::kHostName, 0, false); |
| 309 ASSERT_TRUE(native_message_process_host_.get()); | 309 ASSERT_TRUE(native_message_process_host_.get()); |
| 310 run_loop_.reset(new base::RunLoop()); | 310 run_loop_.reset(new base::RunLoop()); |
| 311 run_loop_->Run(); | 311 run_loop_->Run(); |
| 312 | 312 |
| 313 // The host should fail to start. | 313 // The host should fail to start. |
| 314 ASSERT_TRUE(channel_closed_); | 314 ASSERT_TRUE(channel_closed_); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace extensions | 317 } // namespace extensions |
| OLD | NEW |