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 <iterator> | 9 #include <iterator> |
10 #include <set> | 10 #include <set> |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 referral_list->Append(std::move(motivator)); | 553 referral_list->Append(std::move(motivator)); |
554 } | 554 } |
555 } | 555 } |
556 | 556 |
557 void Predictor::DeserializeReferrers(const base::ListValue& referral_list) { | 557 void Predictor::DeserializeReferrers(const base::ListValue& referral_list) { |
558 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 558 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
559 int format_version = -1; | 559 int format_version = -1; |
560 if (referral_list.GetSize() > 0 && | 560 if (referral_list.GetSize() > 0 && |
561 referral_list.GetInteger(0, &format_version) && | 561 referral_list.GetInteger(0, &format_version) && |
562 format_version == kPredictorReferrerVersion) { | 562 format_version == kPredictorReferrerVersion) { |
| 563 const auto& list = referral_list.base::Value::GetList(); |
563 for (size_t i = 1; i < referral_list.GetSize(); ++i) { | 564 for (size_t i = 1; i < referral_list.GetSize(); ++i) { |
564 const base::ListValue* motivator; | 565 if (!list[i].is_list()) { |
565 if (!referral_list.GetList(i, &motivator)) { | |
566 NOTREACHED(); | 566 NOTREACHED(); |
567 return; | 567 return; |
568 } | 568 } |
| 569 const base::ListValue* motivator = |
| 570 static_cast<const base::ListValue*>(&list[i]); |
569 std::string motivating_url_spec; | 571 std::string motivating_url_spec; |
570 if (!motivator->GetString(0, &motivating_url_spec)) { | 572 if (!motivator->GetString(0, &motivating_url_spec)) { |
571 NOTREACHED(); | 573 NOTREACHED(); |
572 return; | 574 return; |
573 } | 575 } |
574 | 576 |
575 const base::Value* subresource_list; | 577 const base::Value* subresource_list; |
576 if (!motivator->Get(1, &subresource_list)) { | 578 if (!motivator->Get(1, &subresource_list)) { |
577 NOTREACHED(); | 579 NOTREACHED(); |
578 return; | 580 return; |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 } | 1202 } |
1201 | 1203 |
1202 void SimplePredictor::ShutdownOnUIThread() { | 1204 void SimplePredictor::ShutdownOnUIThread() { |
1203 SetShutdown(true); | 1205 SetShutdown(true); |
1204 } | 1206 } |
1205 | 1207 |
1206 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } | 1208 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } |
1207 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } | 1209 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } |
1208 | 1210 |
1209 } // namespace chrome_browser_net | 1211 } // namespace chrome_browser_net |
OLD | NEW |