OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/test/weburl_loader_mock_factory.h" | 5 #include "content/test/weburl_loader_mock_factory.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/test/webkit_support.h" | 10 #include "content/test/webkit_support.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const WebURLResponse& response, | 32 const WebURLResponse& response, |
33 const WebString& file_path) { | 33 const WebString& file_path) { |
34 ResponseInfo response_info; | 34 ResponseInfo response_info; |
35 response_info.response = response; | 35 response_info.response = response; |
36 if (!file_path.isNull() && !file_path.isEmpty()) { | 36 if (!file_path.isNull() && !file_path.isEmpty()) { |
37 #if defined(OS_POSIX) | 37 #if defined(OS_POSIX) |
38 // TODO(jcivelli): On Linux, UTF8 might not be correct. | 38 // TODO(jcivelli): On Linux, UTF8 might not be correct. |
39 response_info.file_path = | 39 response_info.file_path = |
40 base::FilePath(static_cast<std::string>(file_path.utf8())); | 40 base::FilePath(static_cast<std::string>(file_path.utf8())); |
41 #elif defined(OS_WIN) | 41 #elif defined(OS_WIN) |
42 string16 file_path_16 = file_path; | 42 base::string16 file_path_16 = file_path; |
43 response_info.file_path = base::FilePath(std::wstring( | 43 response_info.file_path = base::FilePath(std::wstring( |
44 file_path_16.data(), file_path_16.length())); | 44 file_path_16.data(), file_path_16.length())); |
45 #endif | 45 #endif |
46 DCHECK(base::PathExists(response_info.file_path)) | 46 DCHECK(base::PathExists(response_info.file_path)) |
47 << response_info.file_path.MaybeAsASCII() << " does not exist."; | 47 << response_info.file_path.MaybeAsASCII() << " does not exist."; |
48 } | 48 } |
49 | 49 |
50 DCHECK(url_to_reponse_info_.find(url) == url_to_reponse_info_.end()); | 50 DCHECK(url_to_reponse_info_.find(url) == url_to_reponse_info_.end()); |
51 url_to_reponse_info_[url] = response_info; | 51 url_to_reponse_info_[url] = response_info; |
52 } | 52 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 scoped_ptr<char[]> buffer(new char[size]); | 183 scoped_ptr<char[]> buffer(new char[size]); |
184 data->reset(); | 184 data->reset(); |
185 int read_count = file_util::ReadFile(file_path, buffer.get(), size); | 185 int read_count = file_util::ReadFile(file_path, buffer.get(), size); |
186 if (read_count == -1) | 186 if (read_count == -1) |
187 return false; | 187 return false; |
188 DCHECK(read_count == size); | 188 DCHECK(read_count == size); |
189 data->assign(buffer.get(), size); | 189 data->assign(buffer.get(), size); |
190 | 190 |
191 return true; | 191 return true; |
192 } | 192 } |
OLD | NEW |