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 "net/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 if (calling_delegate_ || !blocked_by_.empty()) { | 272 if (calling_delegate_ || !blocked_by_.empty()) { |
273 return LoadStateWithParam( | 273 return LoadStateWithParam( |
274 LOAD_STATE_WAITING_FOR_DELEGATE, | 274 LOAD_STATE_WAITING_FOR_DELEGATE, |
275 use_blocked_by_as_load_param_ ? base::UTF8ToUTF16(blocked_by_) : | 275 use_blocked_by_as_load_param_ ? base::UTF8ToUTF16(blocked_by_) : |
276 base::string16()); | 276 base::string16()); |
277 } | 277 } |
278 return LoadStateWithParam(job_.get() ? job_->GetLoadState() : LOAD_STATE_IDLE, | 278 return LoadStateWithParam(job_.get() ? job_->GetLoadState() : LOAD_STATE_IDLE, |
279 base::string16()); | 279 base::string16()); |
280 } | 280 } |
281 | 281 |
282 base::Value* URLRequest::GetStateAsValue() const { | 282 base::Value* URLRequest::GetStateAsValue() const { |
eroman
2015/05/08 18:59:47
To complete this, please also make GetStateAsValue
payal.pandey
2015/05/11 12:24:23
Done.
| |
283 base::DictionaryValue* dict = new base::DictionaryValue(); | 283 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
284 dict->SetString("url", original_url().possibly_invalid_spec()); | 284 dict->SetString("url", original_url().possibly_invalid_spec()); |
285 | 285 |
286 if (url_chain_.size() > 1) { | 286 if (url_chain_.size() > 1) { |
287 scoped_ptr<base::ListValue> list(new base::ListValue()); | 287 scoped_ptr<base::ListValue> list(new base::ListValue()); |
288 for (const GURL& url : url_chain_) { | 288 for (const GURL& url : url_chain_) { |
289 list->AppendString(url.possibly_invalid_spec()); | 289 list->AppendString(url.possibly_invalid_spec()); |
290 } | 290 } |
291 dict->Set("url_chain", list.Pass()); | 291 dict->Set("url_chain", list.Pass()); |
292 } | 292 } |
293 | 293 |
(...skipping 22 matching lines...) Expand all Loading... | |
316 break; | 316 break; |
317 case URLRequestStatus::CANCELED: | 317 case URLRequestStatus::CANCELED: |
318 dict->SetString("status", "CANCELED"); | 318 dict->SetString("status", "CANCELED"); |
319 break; | 319 break; |
320 case URLRequestStatus::FAILED: | 320 case URLRequestStatus::FAILED: |
321 dict->SetString("status", "FAILED"); | 321 dict->SetString("status", "FAILED"); |
322 break; | 322 break; |
323 } | 323 } |
324 if (status_.error() != OK) | 324 if (status_.error() != OK) |
325 dict->SetInteger("net_error", status_.error()); | 325 dict->SetInteger("net_error", status_.error()); |
326 return dict; | 326 return dict.release(); |
327 } | 327 } |
328 | 328 |
329 void URLRequest::LogBlockedBy(const char* blocked_by) { | 329 void URLRequest::LogBlockedBy(const char* blocked_by) { |
330 DCHECK(blocked_by); | 330 DCHECK(blocked_by); |
331 DCHECK_GT(strlen(blocked_by), 0u); | 331 DCHECK_GT(strlen(blocked_by), 0u); |
332 | 332 |
333 // Only log information to NetLog during startup and certain deferring calls | 333 // Only log information to NetLog during startup and certain deferring calls |
334 // to delegates. For all reads but the first, do nothing. | 334 // to delegates. For all reads but the first, do nothing. |
335 if (!calling_delegate_ && !response_info_.request_time.is_null()) | 335 if (!calling_delegate_ && !response_info_.request_time.is_null()) |
336 return; | 336 return; |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1183 new base::debug::StackTrace(NULL, 0); | 1183 new base::debug::StackTrace(NULL, 0); |
1184 *stack_trace_copy = stack_trace; | 1184 *stack_trace_copy = stack_trace; |
1185 stack_trace_.reset(stack_trace_copy); | 1185 stack_trace_.reset(stack_trace_copy); |
1186 } | 1186 } |
1187 | 1187 |
1188 const base::debug::StackTrace* URLRequest::stack_trace() const { | 1188 const base::debug::StackTrace* URLRequest::stack_trace() const { |
1189 return stack_trace_.get(); | 1189 return stack_trace_.get(); |
1190 } | 1190 } |
1191 | 1191 |
1192 } // namespace net | 1192 } // namespace net |
OLD | NEW |