Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/url_request/url_request_netlog_params.h" |
| 6 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 7 | #include "base/strings/string_number_conversions.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 8 | #include "base/values.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 9 | #include "url/gurl.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 10 | |
| 11 | namespace net { |
| 12 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 13 | base::Value* NetLogURLRequestStartCallback(const GURL* url, |
| 14 | const std::string* method, |
| 15 | int load_flags, |
| 16 | RequestPriority priority, |
| 17 | int64 upload_id, |
| 18 | NetLog::LogLevel /* log_level */) { |
| 19 | base::DictionaryValue* dict = new base::DictionaryValue(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 20 | dict->SetString("url", url->possibly_invalid_spec()); |
| 21 | dict->SetString("method", *method); |
| 22 | dict->SetInteger("load_flags", load_flags); |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame] | 23 | dict->SetString("priority", RequestPriorityToString(priority)); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 24 | if (upload_id > -1) |
| 25 | dict->SetString("upload_id", base::Int64ToString(upload_id)); |
| 26 | return dict; |
| 27 | } |
| 28 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 29 | bool StartEventLoadFlagsFromEventParams(const base::Value* event_params, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 30 | int* load_flags) { |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 31 | const base::DictionaryValue* dict; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 32 | if (!event_params->GetAsDictionary(&dict) || |
| 33 | !dict->GetInteger("load_flags", load_flags)) { |
| 34 | *load_flags = 0; |
| 35 | return false; |
| 36 | } |
| 37 | return true; |
| 38 | } |
| 39 | |
| 40 | } // namespace net |