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 "chrome/browser/net/predictor.h" | 5 #include "chrome/browser/net/predictor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <sstream> | 11 #include <sstream> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
21 #include "base/values.h" | 22 #include "base/values.h" |
22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
23 #include "chrome/browser/net/url_info.h" | 24 #include "chrome/browser/net/url_info.h" |
24 #include "content/public/test/test_browser_thread.h" | 25 #include "content/public/test/test_browser_thread.h" |
25 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 double use_rate, | 95 double use_rate, |
95 base::ListValue* referral_list) { | 96 base::ListValue* referral_list) { |
96 // Find the motivation if it is already used. | 97 // Find the motivation if it is already used. |
97 base::ListValue* motivation_list = | 98 base::ListValue* motivation_list = |
98 FindSerializationMotivation(motivation, referral_list); | 99 FindSerializationMotivation(motivation, referral_list); |
99 if (!motivation_list) { | 100 if (!motivation_list) { |
100 // This is the first mention of this motivation, so build a list. | 101 // This is the first mention of this motivation, so build a list. |
101 motivation_list = new base::ListValue; | 102 motivation_list = new base::ListValue; |
102 motivation_list->AppendString(motivation.spec()); | 103 motivation_list->AppendString(motivation.spec()); |
103 // Provide empty subresource list. | 104 // Provide empty subresource list. |
104 motivation_list->Append(new base::ListValue()); | 105 motivation_list->Append(base::MakeUnique<base::ListValue>()); |
105 | 106 |
106 // ...and make it part of the serialized referral_list. | 107 // ...and make it part of the serialized referral_list. |
107 referral_list->Append(motivation_list); | 108 referral_list->Append(base::WrapUnique(motivation_list)); |
108 } | 109 } |
109 | 110 |
110 base::ListValue* subresource_list(NULL); | 111 base::ListValue* subresource_list(NULL); |
111 // 0 == url; 1 == subresource_list. | 112 // 0 == url; 1 == subresource_list. |
112 EXPECT_TRUE(motivation_list->GetList(1, &subresource_list)); | 113 EXPECT_TRUE(motivation_list->GetList(1, &subresource_list)); |
113 | 114 |
114 // We won't bother to check for the subresource being there already. Worst | 115 // We won't bother to check for the subresource being there already. Worst |
115 // case, during deserialization, the latency value we supply plus the | 116 // case, during deserialization, the latency value we supply plus the |
116 // existing value(s) will be added to the referrer. | 117 // existing value(s) will be added to the referrer. |
117 | 118 |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); | 560 testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED); |
560 | 561 |
561 // Proxy may not be in use (the PAC script has not yet been evaluated), so the | 562 // Proxy may not be in use (the PAC script has not yet been evaluated), so the |
562 // name has been registered for pre-resolve. | 563 // name has been registered for pre-resolve. |
563 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); | 564 EXPECT_FALSE(testing_master.work_queue_.IsEmpty()); |
564 | 565 |
565 testing_master.Shutdown(); | 566 testing_master.Shutdown(); |
566 } | 567 } |
567 | 568 |
568 } // namespace chrome_browser_net | 569 } // namespace chrome_browser_net |
OLD | NEW |