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

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

Issue 842523002: base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheck2: withoutandroidchange Created 5 years, 11 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
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/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 HttpBridge::~HttpBridge() { 210 HttpBridge::~HttpBridge() {
211 } 211 }
212 212
213 void HttpBridge::SetExtraRequestHeaders(const char * headers) { 213 void HttpBridge::SetExtraRequestHeaders(const char * headers) {
214 DCHECK(extra_headers_.empty()) 214 DCHECK(extra_headers_.empty())
215 << "HttpBridge::SetExtraRequestHeaders called twice."; 215 << "HttpBridge::SetExtraRequestHeaders called twice.";
216 extra_headers_.assign(headers); 216 extra_headers_.assign(headers);
217 } 217 }
218 218
219 void HttpBridge::SetURL(const char* url, int port) { 219 void HttpBridge::SetURL(const char* url, int port) {
220 #if DCHECK_IS_ON 220 #if DCHECK_IS_ON()
221 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_); 221 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_);
222 { 222 {
223 base::AutoLock lock(fetch_state_lock_); 223 base::AutoLock lock(fetch_state_lock_);
224 DCHECK(!fetch_state_.request_completed); 224 DCHECK(!fetch_state_.request_completed);
225 } 225 }
226 DCHECK(url_for_request_.is_empty()) 226 DCHECK(url_for_request_.is_empty())
227 << "HttpBridge::SetURL called more than once?!"; 227 << "HttpBridge::SetURL called more than once?!";
228 #endif 228 #endif
229 GURL temp(url); 229 GURL temp(url);
230 GURL::Replacements replacements; 230 GURL::Replacements replacements;
231 std::string port_str = base::IntToString(port); 231 std::string port_str = base::IntToString(port);
232 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.length())); 232 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.length()));
233 url_for_request_ = temp.ReplaceComponents(replacements); 233 url_for_request_ = temp.ReplaceComponents(replacements);
234 } 234 }
235 235
236 void HttpBridge::SetPostPayload(const char* content_type, 236 void HttpBridge::SetPostPayload(const char* content_type,
237 int content_length, 237 int content_length,
238 const char* content) { 238 const char* content) {
239 #if DCHECK_IS_ON 239 #if DCHECK_IS_ON()
240 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_); 240 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_);
241 { 241 {
242 base::AutoLock lock(fetch_state_lock_); 242 base::AutoLock lock(fetch_state_lock_);
243 DCHECK(!fetch_state_.request_completed); 243 DCHECK(!fetch_state_.request_completed);
244 } 244 }
245 DCHECK(content_type_.empty()) << "Bridge payload already set."; 245 DCHECK(content_type_.empty()) << "Bridge payload already set.";
246 DCHECK_GE(content_length, 0) << "Content length < 0"; 246 DCHECK_GE(content_length, 0) << "Content length < 0";
247 #endif 247 #endif
248 content_type_ = content_type; 248 content_type_ = content_type;
249 if (!content || (content_length == 0)) { 249 if (!content || (content_length == 0)) {
250 DCHECK_EQ(content_length, 0); 250 DCHECK_EQ(content_length, 0);
251 request_content_ = " "; // TODO(timsteele): URLFetcher requires non-empty 251 request_content_ = " "; // TODO(timsteele): URLFetcher requires non-empty
252 // content for POSTs whereas CURL does not, for now 252 // content for POSTs whereas CURL does not, for now
253 // we hack this to support the sync backend. 253 // we hack this to support the sync backend.
254 } else { 254 } else {
255 request_content_.assign(content, content_length); 255 request_content_.assign(content, content_length);
256 } 256 }
257 } 257 }
258 258
259 bool HttpBridge::MakeSynchronousPost(int* error_code, int* response_code) { 259 bool HttpBridge::MakeSynchronousPost(int* error_code, int* response_code) {
260 #if DCHECK_IS_ON 260 #if DCHECK_IS_ON()
261 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_); 261 DCHECK_EQ(base::MessageLoop::current(), created_on_loop_);
262 { 262 {
263 base::AutoLock lock(fetch_state_lock_); 263 base::AutoLock lock(fetch_state_lock_);
264 DCHECK(!fetch_state_.request_completed); 264 DCHECK(!fetch_state_.request_completed);
265 } 265 }
266 DCHECK(url_for_request_.is_valid()) << "Invalid URL for request"; 266 DCHECK(url_for_request_.is_valid()) << "Invalid URL for request";
267 DCHECK(!content_type_.empty()) << "Payload not set"; 267 DCHECK(!content_type_.empty()) << "Payload not set";
268 #endif 268 #endif
269 269
270 if (!network_task_runner_->PostTask( 270 if (!network_task_runner_->PostTask(
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 int64 sane_time_ms = 0; 486 int64 sane_time_ms = 0;
487 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { 487 if (base::StringToInt64(sane_time_str, &sane_time_ms)) {
488 network_time_update_callback_.Run( 488 network_time_update_callback_.Run(
489 base::Time::FromJsTime(sane_time_ms), 489 base::Time::FromJsTime(sane_time_ms),
490 base::TimeDelta::FromMilliseconds(1), 490 base::TimeDelta::FromMilliseconds(1),
491 fetch_state_.end_time - fetch_state_.start_time); 491 fetch_state_.end_time - fetch_state_.start_time);
492 } 492 }
493 } 493 }
494 494
495 } // namespace syncer 495 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698