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

Side by Side Diff: sync/internal_api/http_bridge.cc

Issue 195973002: Change DCHECK_IS_ON() to DCHECK_IS_ON (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "sync/internal_api/public/http_bridge.h" 5 #include "sync/internal_api/public/http_bridge.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 void HttpBridge::SetExtraRequestHeaders(const char * headers) { 194 void HttpBridge::SetExtraRequestHeaders(const char * headers) {
195 DCHECK(extra_headers_.empty()) 195 DCHECK(extra_headers_.empty())
196 << "HttpBridge::SetExtraRequestHeaders called twice."; 196 << "HttpBridge::SetExtraRequestHeaders called twice.";
197 extra_headers_.assign(headers); 197 extra_headers_.assign(headers);
198 } 198 }
199 199
200 void HttpBridge::SetURL(const char* url, int port) { 200 void HttpBridge::SetURL(const char* url, int port) {
201 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_); 201 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_);
202 if (DCHECK_IS_ON()) { 202 if (DCHECK_IS_ON) {
203 base::AutoLock lock(fetch_state_lock_); 203 base::AutoLock lock(fetch_state_lock_);
204 DCHECK(!fetch_state_.request_completed); 204 DCHECK(!fetch_state_.request_completed);
205 } 205 }
206 DCHECK(url_for_request_.is_empty()) 206 DCHECK(url_for_request_.is_empty())
207 << "HttpBridge::SetURL called more than once?!"; 207 << "HttpBridge::SetURL called more than once?!";
208 GURL temp(url); 208 GURL temp(url);
209 GURL::Replacements replacements; 209 GURL::Replacements replacements;
210 std::string port_str = base::IntToString(port); 210 std::string port_str = base::IntToString(port);
211 replacements.SetPort(port_str.c_str(), 211 replacements.SetPort(port_str.c_str(),
212 url_parse::Component(0, port_str.length())); 212 url_parse::Component(0, port_str.length()));
213 url_for_request_ = temp.ReplaceComponents(replacements); 213 url_for_request_ = temp.ReplaceComponents(replacements);
214 } 214 }
215 215
216 void HttpBridge::SetPostPayload(const char* content_type, 216 void HttpBridge::SetPostPayload(const char* content_type,
217 int content_length, 217 int content_length,
218 const char* content) { 218 const char* content) {
219 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_); 219 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_);
220 if (DCHECK_IS_ON()) { 220 if (DCHECK_IS_ON) {
221 base::AutoLock lock(fetch_state_lock_); 221 base::AutoLock lock(fetch_state_lock_);
222 DCHECK(!fetch_state_.request_completed); 222 DCHECK(!fetch_state_.request_completed);
223 } 223 }
224 DCHECK(content_type_.empty()) << "Bridge payload already set."; 224 DCHECK(content_type_.empty()) << "Bridge payload already set.";
225 DCHECK_GE(content_length, 0) << "Content length < 0"; 225 DCHECK_GE(content_length, 0) << "Content length < 0";
226 content_type_ = content_type; 226 content_type_ = content_type;
227 if (!content || (content_length == 0)) { 227 if (!content || (content_length == 0)) {
228 DCHECK_EQ(content_length, 0); 228 DCHECK_EQ(content_length, 0);
229 request_content_ = " "; // TODO(timsteele): URLFetcher requires non-empty 229 request_content_ = " "; // TODO(timsteele): URLFetcher requires non-empty
230 // content for POSTs whereas CURL does not, for now 230 // content for POSTs whereas CURL does not, for now
231 // we hack this to support the sync backend. 231 // we hack this to support the sync backend.
232 } else { 232 } else {
233 request_content_.assign(content, content_length); 233 request_content_.assign(content, content_length);
234 } 234 }
235 } 235 }
236 236
237 bool HttpBridge::MakeSynchronousPost(int* error_code, int* response_code) { 237 bool HttpBridge::MakeSynchronousPost(int* error_code, int* response_code) {
238 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_); 238 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_);
239 if (DCHECK_IS_ON()) { 239 if (DCHECK_IS_ON) {
240 base::AutoLock lock(fetch_state_lock_); 240 base::AutoLock lock(fetch_state_lock_);
241 DCHECK(!fetch_state_.request_completed); 241 DCHECK(!fetch_state_.request_completed);
242 } 242 }
243 DCHECK(url_for_request_.is_valid()) << "Invalid URL for request"; 243 DCHECK(url_for_request_.is_valid()) << "Invalid URL for request";
244 DCHECK(!content_type_.empty()) << "Payload not set"; 244 DCHECK(!content_type_.empty()) << "Payload not set";
245 245
246 if (!network_task_runner_->PostTask( 246 if (!network_task_runner_->PostTask(
247 FROM_HERE, 247 FROM_HERE,
248 base::Bind(&HttpBridge::CallMakeAsynchronousPost, this))) { 248 base::Bind(&HttpBridge::CallMakeAsynchronousPost, this))) {
249 // This usually happens when we're in a unit test. 249 // This usually happens when we're in a unit test.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 int64 sane_time_ms = 0; 388 int64 sane_time_ms = 0;
389 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { 389 if (base::StringToInt64(sane_time_str, &sane_time_ms)) {
390 network_time_update_callback_.Run( 390 network_time_update_callback_.Run(
391 base::Time::FromJsTime(sane_time_ms), 391 base::Time::FromJsTime(sane_time_ms),
392 base::TimeDelta::FromMilliseconds(1), 392 base::TimeDelta::FromMilliseconds(1),
393 fetch_state_.end_time - fetch_state_.start_time); 393 fetch_state_.end_time - fetch_state_.start_time);
394 } 394 }
395 } 395 }
396 396
397 } // namespace syncer 397 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698