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 "webkit/support/weburl_loader_mock_factory.h" | 5 #include "webkit/support/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 "third_party/WebKit/public/platform/WebString.h" | 9 #include "third_party/WebKit/public/platform/WebString.h" |
10 #include "third_party/WebKit/public/platform/WebURLError.h" | 10 #include "third_party/WebKit/public/platform/WebURLError.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 if (!file_path.isNull() && !file_path.isEmpty()) { | 40 if (!file_path.isNull() && !file_path.isEmpty()) { |
41 #if defined(OS_POSIX) | 41 #if defined(OS_POSIX) |
42 // TODO(jcivelli): On Linux, UTF8 might not be correct. | 42 // TODO(jcivelli): On Linux, UTF8 might not be correct. |
43 response_info.file_path = | 43 response_info.file_path = |
44 base::FilePath(static_cast<std::string>(file_path.utf8())); | 44 base::FilePath(static_cast<std::string>(file_path.utf8())); |
45 #elif defined(OS_WIN) | 45 #elif defined(OS_WIN) |
46 string16 file_path_16 = file_path; | 46 string16 file_path_16 = file_path; |
47 response_info.file_path = base::FilePath(std::wstring( | 47 response_info.file_path = base::FilePath(std::wstring( |
48 file_path_16.data(), file_path_16.length())); | 48 file_path_16.data(), file_path_16.length())); |
49 #endif | 49 #endif |
50 DCHECK(file_util::PathExists(response_info.file_path)) | 50 DCHECK(base::PathExists(response_info.file_path)) |
51 << response_info.file_path.MaybeAsASCII() << " does not exist."; | 51 << response_info.file_path.MaybeAsASCII() << " does not exist."; |
52 } | 52 } |
53 | 53 |
54 DCHECK(url_to_reponse_info_.find(url) == url_to_reponse_info_.end()); | 54 DCHECK(url_to_reponse_info_.find(url) == url_to_reponse_info_.end()); |
55 url_to_reponse_info_[url] = response_info; | 55 url_to_reponse_info_[url] = response_info; |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 void WebURLLoaderMockFactory::RegisterErrorURL(const WebURL& url, | 59 void WebURLLoaderMockFactory::RegisterErrorURL(const WebURL& url, |
60 const WebURLResponse& response, | 60 const WebURLResponse& response, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 scoped_ptr<char[]> buffer(new char[size]); | 187 scoped_ptr<char[]> buffer(new char[size]); |
188 data->reset(); | 188 data->reset(); |
189 int read_count = file_util::ReadFile(file_path, buffer.get(), size); | 189 int read_count = file_util::ReadFile(file_path, buffer.get(), size); |
190 if (read_count == -1) | 190 if (read_count == -1) |
191 return false; | 191 return false; |
192 DCHECK(read_count == size); | 192 DCHECK(read_count == size); |
193 data->assign(buffer.get(), size); | 193 data->assign(buffer.get(), size); |
194 | 194 |
195 return true; | 195 return true; |
196 } | 196 } |
OLD | NEW |