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 <stdint.h> |
| 8 |
7 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "build/build_config.h" |
10 #include "content/test/weburl_loader_mock.h" | 13 #include "content/test/weburl_loader_mock.h" |
11 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
12 #include "third_party/WebKit/public/platform/WebURLError.h" | 15 #include "third_party/WebKit/public/platform/WebURLError.h" |
13 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 16 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
14 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 17 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
15 #include "third_party/WebKit/public/web/WebCache.h" | 18 #include "third_party/WebKit/public/web/WebCache.h" |
16 | 19 |
17 using blink::WebCache; | 20 using blink::WebCache; |
18 using blink::WebData; | 21 using blink::WebData; |
19 using blink::WebString; | 22 using blink::WebString; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 165 } |
163 | 166 |
164 // static | 167 // static |
165 bool WebURLLoaderMockFactory::ReadFile(const base::FilePath& file_path, | 168 bool WebURLLoaderMockFactory::ReadFile(const base::FilePath& file_path, |
166 WebData* data) { | 169 WebData* data) { |
167 // If the path is empty then we return an empty file so tests can simulate | 170 // If the path is empty then we return an empty file so tests can simulate |
168 // requests without needing to actually load files. | 171 // requests without needing to actually load files. |
169 if (file_path.empty()) | 172 if (file_path.empty()) |
170 return true; | 173 return true; |
171 | 174 |
172 int64 file_size = 0; | 175 int64_t file_size = 0; |
173 if (!base::GetFileSize(file_path, &file_size)) | 176 if (!base::GetFileSize(file_path, &file_size)) |
174 return false; | 177 return false; |
175 | 178 |
176 int size = static_cast<int>(file_size); | 179 int size = static_cast<int>(file_size); |
177 scoped_ptr<char[]> buffer(new char[size]); | 180 scoped_ptr<char[]> buffer(new char[size]); |
178 data->reset(); | 181 data->reset(); |
179 int read_count = base::ReadFile(file_path, buffer.get(), size); | 182 int read_count = base::ReadFile(file_path, buffer.get(), size); |
180 if (read_count == -1) | 183 if (read_count == -1) |
181 return false; | 184 return false; |
182 DCHECK(read_count == size); | 185 DCHECK(read_count == size); |
183 data->assign(buffer.get(), size); | 186 data->assign(buffer.get(), size); |
184 | 187 |
185 return true; | 188 return true; |
186 } | 189 } |
OLD | NEW |