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_netlog_params.h" | 5 #include "net/url_request/url_request_netlog_params.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 base::Value* NetLogURLRequestStartCallback( | 13 scoped_ptr<base::Value> NetLogURLRequestStartCallback( |
14 const GURL* url, | 14 const GURL* url, |
15 const std::string* method, | 15 const std::string* method, |
16 int load_flags, | 16 int load_flags, |
17 RequestPriority priority, | 17 RequestPriority priority, |
18 int64 upload_id, | 18 int64 upload_id, |
19 NetLogCaptureMode /* capture_mode */) { | 19 NetLogCaptureMode /* capture_mode */) { |
20 base::DictionaryValue* dict = new base::DictionaryValue(); | 20 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
21 dict->SetString("url", url->possibly_invalid_spec()); | 21 dict->SetString("url", url->possibly_invalid_spec()); |
22 dict->SetString("method", *method); | 22 dict->SetString("method", *method); |
23 dict->SetInteger("load_flags", load_flags); | 23 dict->SetInteger("load_flags", load_flags); |
24 dict->SetString("priority", RequestPriorityToString(priority)); | 24 dict->SetString("priority", RequestPriorityToString(priority)); |
25 if (upload_id > -1) | 25 if (upload_id > -1) |
26 dict->SetString("upload_id", base::Int64ToString(upload_id)); | 26 dict->SetString("upload_id", base::Int64ToString(upload_id)); |
27 return dict; | 27 return dict.Pass(); |
28 } | 28 } |
29 | 29 |
30 bool StartEventLoadFlagsFromEventParams(const base::Value* event_params, | 30 bool StartEventLoadFlagsFromEventParams(const base::Value* event_params, |
31 int* load_flags) { | 31 int* load_flags) { |
32 const base::DictionaryValue* dict; | 32 const base::DictionaryValue* dict; |
33 if (!event_params->GetAsDictionary(&dict) || | 33 if (!event_params->GetAsDictionary(&dict) || |
34 !dict->GetInteger("load_flags", load_flags)) { | 34 !dict->GetInteger("load_flags", load_flags)) { |
35 *load_flags = 0; | 35 *load_flags = 0; |
36 return false; | 36 return false; |
37 } | 37 } |
38 return true; | 38 return true; |
39 } | 39 } |
40 | 40 |
41 } // namespace net | 41 } // namespace net |
OLD | NEW |