| 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 "google_apis/drive/test_util.h" | 5 #include "google_apis/drive/test_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 std::unique_ptr<net::test_server::HttpResponse> HandleDownloadFileRequest( | 111 std::unique_ptr<net::test_server::HttpResponse> HandleDownloadFileRequest( |
| 112 const GURL& base_url, | 112 const GURL& base_url, |
| 113 net::test_server::HttpRequest* out_request, | 113 net::test_server::HttpRequest* out_request, |
| 114 const net::test_server::HttpRequest& request) { | 114 const net::test_server::HttpRequest& request) { |
| 115 *out_request = request; | 115 *out_request = request; |
| 116 | 116 |
| 117 GURL absolute_url = base_url.Resolve(request.relative_url); | 117 GURL absolute_url = base_url.Resolve(request.relative_url); |
| 118 std::string remaining_path; | 118 std::string remaining_path; |
| 119 if (!RemovePrefix(absolute_url.path(), "/files/", &remaining_path)) | 119 if (!RemovePrefix(absolute_url.path().as_string(), "/files/", |
| 120 &remaining_path)) { |
| 120 return std::unique_ptr<net::test_server::HttpResponse>(); | 121 return std::unique_ptr<net::test_server::HttpResponse>(); |
| 122 } |
| 121 return CreateHttpResponseFromFile(GetTestFilePath(remaining_path)); | 123 return CreateHttpResponseFromFile(GetTestFilePath(remaining_path)); |
| 122 } | 124 } |
| 123 | 125 |
| 124 bool ParseContentRangeHeader(const std::string& value, | 126 bool ParseContentRangeHeader(const std::string& value, |
| 125 int64_t* start_position, | 127 int64_t* start_position, |
| 126 int64_t* end_position, | 128 int64_t* end_position, |
| 127 int64_t* length) { | 129 int64_t* length) { |
| 128 DCHECK(start_position); | 130 DCHECK(start_position); |
| 129 DCHECK(end_position); | 131 DCHECK(end_position); |
| 130 DCHECK(length); | 132 DCHECK(length); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return result; | 174 return result; |
| 173 } | 175 } |
| 174 | 176 |
| 175 void TestGetContentCallback::OnGetContent(google_apis::DriveApiErrorCode error, | 177 void TestGetContentCallback::OnGetContent(google_apis::DriveApiErrorCode error, |
| 176 std::unique_ptr<std::string> data) { | 178 std::unique_ptr<std::string> data) { |
| 177 data_.push_back(data.release()); | 179 data_.push_back(data.release()); |
| 178 } | 180 } |
| 179 | 181 |
| 180 } // namespace test_util | 182 } // namespace test_util |
| 181 } // namespace google_apis | 183 } // namespace google_apis |
| OLD | NEW |