Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: google_apis/drive/test_util.cc

Issue 1548673002: Switch to standard integer types in google_apis/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « google_apis/drive/test_util.h ('k') | google_apis/gaia/fake_gaia.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(), "/files/", &remaining_path))
120 return scoped_ptr<net::test_server::HttpResponse>(); 120 return scoped_ptr<net::test_server::HttpResponse>();
121 return CreateHttpResponseFromFile(GetTestFilePath(remaining_path)); 121 return CreateHttpResponseFromFile(GetTestFilePath(remaining_path));
122 } 122 }
123 123
124 bool ParseContentRangeHeader(const std::string& value, 124 bool ParseContentRangeHeader(const std::string& value,
125 int64* start_position, 125 int64_t* start_position,
126 int64* end_position, 126 int64_t* end_position,
127 int64* length) { 127 int64_t* length) {
128 DCHECK(start_position); 128 DCHECK(start_position);
129 DCHECK(end_position); 129 DCHECK(end_position);
130 DCHECK(length); 130 DCHECK(length);
131 131
132 std::string remaining; 132 std::string remaining;
133 if (!RemovePrefix(value, "bytes ", &remaining)) 133 if (!RemovePrefix(value, "bytes ", &remaining))
134 return false; 134 return false;
135 135
136 std::vector<base::StringPiece> parts = base::SplitStringPiece( 136 std::vector<base::StringPiece> parts = base::SplitStringPiece(
137 remaining, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 137 remaining, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
138 if (parts.size() != 2U) 138 if (parts.size() != 2U)
139 return false; 139 return false;
140 140
141 if (!base::StringToInt64(parts[1], length)) 141 if (!base::StringToInt64(parts[1], length))
142 return false; 142 return false;
143 143
144 parts = base::SplitStringPiece(parts[0], "-", base::TRIM_WHITESPACE, 144 parts = base::SplitStringPiece(parts[0], "-", base::TRIM_WHITESPACE,
145 base::SPLIT_WANT_ALL); 145 base::SPLIT_WANT_ALL);
146 if (parts.size() != 2U) 146 if (parts.size() != 2U)
147 return false; 147 return false;
148 148
149 return (base::StringToInt64(parts[0], start_position) && 149 return (base::StringToInt64(parts[0], start_position) &&
150 base::StringToInt64(parts[1], end_position)); 150 base::StringToInt64(parts[1], end_position));
151 } 151 }
152 152
153 void AppendProgressCallbackResult(std::vector<ProgressInfo>* progress_values, 153 void AppendProgressCallbackResult(std::vector<ProgressInfo>* progress_values,
154 int64 progress, 154 int64_t progress,
155 int64 total) { 155 int64_t total) {
156 progress_values->push_back(ProgressInfo(progress, total)); 156 progress_values->push_back(ProgressInfo(progress, total));
157 } 157 }
158 158
159 TestGetContentCallback::TestGetContentCallback() 159 TestGetContentCallback::TestGetContentCallback()
160 : callback_(base::Bind(&TestGetContentCallback::OnGetContent, 160 : callback_(base::Bind(&TestGetContentCallback::OnGetContent,
161 base::Unretained(this))) { 161 base::Unretained(this))) {
162 } 162 }
163 163
164 TestGetContentCallback::~TestGetContentCallback() { 164 TestGetContentCallback::~TestGetContentCallback() {
165 } 165 }
166 166
167 std::string TestGetContentCallback::GetConcatenatedData() const { 167 std::string TestGetContentCallback::GetConcatenatedData() const {
168 std::string result; 168 std::string result;
169 for (size_t i = 0; i < data_.size(); ++i) { 169 for (size_t i = 0; i < data_.size(); ++i) {
170 result += *data_[i]; 170 result += *data_[i];
171 } 171 }
172 return result; 172 return result;
173 } 173 }
174 174
175 void TestGetContentCallback::OnGetContent(google_apis::DriveApiErrorCode error, 175 void TestGetContentCallback::OnGetContent(google_apis::DriveApiErrorCode error,
176 scoped_ptr<std::string> data) { 176 scoped_ptr<std::string> data) {
177 data_.push_back(data.release()); 177 data_.push_back(data.release());
178 } 178 }
179 179
180 } // namespace test_util 180 } // namespace test_util
181 } // namespace google_apis 181 } // namespace google_apis
OLDNEW
« no previous file with comments | « google_apis/drive/test_util.h ('k') | google_apis/gaia/fake_gaia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698