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 <time.h> | 5 #include <time.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 EXPECT_TRUE(motivation_list->GetList(1, &subresource_list)); | 305 EXPECT_TRUE(motivation_list->GetList(1, &subresource_list)); |
306 | 306 |
307 // We won't bother to check for the subresource being there already. Worst | 307 // We won't bother to check for the subresource being there already. Worst |
308 // case, during deserialization, the latency value we supply plus the | 308 // case, during deserialization, the latency value we supply plus the |
309 // existing value(s) will be added to the referrer. | 309 // existing value(s) will be added to the referrer. |
310 | 310 |
311 subresource_list->Append(new base::StringValue(subresource.spec())); | 311 subresource_list->Append(new base::StringValue(subresource.spec())); |
312 subresource_list->Append(new base::FundamentalValue(use_rate)); | 312 subresource_list->Append(new base::FundamentalValue(use_rate)); |
313 } | 313 } |
314 | 314 |
315 static const int kLatencyNotFound = -1; | |
316 | |
317 // For a given motivation, and subresource, find what latency is currently | 315 // For a given motivation, and subresource, find what latency is currently |
318 // listed. This assume a well formed serialization, which has at most one such | 316 // listed. This assume a well formed serialization, which has at most one such |
319 // entry for any pair of names. If no such pair is found, then return false. | 317 // entry for any pair of names. If no such pair is found, then return false. |
320 // Data is written into use_rate arguments. | 318 // Data is written into use_rate arguments. |
321 static bool GetDataFromSerialization(const GURL& motivation, | 319 static bool GetDataFromSerialization(const GURL& motivation, |
322 const GURL& subresource, | 320 const GURL& subresource, |
323 const ListValue& referral_list, | 321 const ListValue& referral_list, |
324 double* use_rate) { | 322 double* use_rate) { |
325 const ListValue* motivation_list = | 323 const ListValue* motivation_list = |
326 FindSerializationMotivation(motivation, &referral_list); | 324 FindSerializationMotivation(motivation, &referral_list); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 EXPECT_EQ(2U, referral_list.GetSize()); | 673 EXPECT_EQ(2U, referral_list.GetSize()); |
676 | 674 |
677 predictor.DiscardAllResults(); | 675 predictor.DiscardAllResults(); |
678 predictor.SerializeReferrers(&referral_list); | 676 predictor.SerializeReferrers(&referral_list); |
679 EXPECT_EQ(1U, referral_list.GetSize()); | 677 EXPECT_EQ(1U, referral_list.GetSize()); |
680 | 678 |
681 predictor.Shutdown(); | 679 predictor.Shutdown(); |
682 } | 680 } |
683 | 681 |
684 } // namespace chrome_browser_net | 682 } // namespace chrome_browser_net |
OLD | NEW |