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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 #include <sstream> | 10 #include <sstream> |
| 11 #include <utility> |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/containers/mru_cache.h" | 15 #include "base/containers/mru_cache.h" |
15 #include "base/feature_list.h" | 16 #include "base/feature_list.h" |
16 #include "base/location.h" | 17 #include "base/location.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 void Predictor::SerializeReferrers(base::ListValue* referral_list) { | 589 void Predictor::SerializeReferrers(base::ListValue* referral_list) { |
589 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 590 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
590 referral_list->Clear(); | 591 referral_list->Clear(); |
591 referral_list->AppendInteger(kPredictorReferrerVersion); | 592 referral_list->AppendInteger(kPredictorReferrerVersion); |
592 for (Referrers::const_iterator it = referrers_.begin(); | 593 for (Referrers::const_iterator it = referrers_.begin(); |
593 it != referrers_.end(); ++it) { | 594 it != referrers_.end(); ++it) { |
594 // Serialize the list of subresource names. | 595 // Serialize the list of subresource names. |
595 base::Value* subresource_list(it->second.Serialize()); | 596 base::Value* subresource_list(it->second.Serialize()); |
596 | 597 |
597 // Create a list for each referer. | 598 // Create a list for each referer. |
598 base::ListValue* motivator(new base::ListValue); | 599 std::unique_ptr<base::ListValue> motivator(new base::ListValue); |
599 motivator->AppendString(it->first.spec()); | 600 motivator->AppendString(it->first.spec()); |
600 motivator->Append(subresource_list); | 601 motivator->Append(subresource_list); |
601 | 602 |
602 referral_list->Append(motivator); | 603 referral_list->Append(std::move(motivator)); |
603 } | 604 } |
604 } | 605 } |
605 | 606 |
606 void Predictor::DeserializeReferrers(const base::ListValue& referral_list) { | 607 void Predictor::DeserializeReferrers(const base::ListValue& referral_list) { |
607 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 608 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
608 int format_version = -1; | 609 int format_version = -1; |
609 if (referral_list.GetSize() > 0 && | 610 if (referral_list.GetSize() > 0 && |
610 referral_list.GetInteger(0, &format_version) && | 611 referral_list.GetInteger(0, &format_version) && |
611 format_version == kPredictorReferrerVersion) { | 612 format_version == kPredictorReferrerVersion) { |
612 for (size_t i = 1; i < referral_list.GetSize(); ++i) { | 613 for (size_t i = 1; i < referral_list.GetSize(); ++i) { |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 } | 1316 } |
1316 | 1317 |
1317 void SimplePredictor::ShutdownOnUIThread() { | 1318 void SimplePredictor::ShutdownOnUIThread() { |
1318 SetShutdown(true); | 1319 SetShutdown(true); |
1319 } | 1320 } |
1320 | 1321 |
1321 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } | 1322 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } |
1322 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } | 1323 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } |
1323 | 1324 |
1324 } // namespace chrome_browser_net | 1325 } // namespace chrome_browser_net |
OLD | NEW |