OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 599 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
600 // Just finish up work if an incremental trim is in progress. | 600 // Just finish up work if an incremental trim is in progress. |
601 if (urls_being_trimmed_.empty()) | 601 if (urls_being_trimmed_.empty()) |
602 LoadUrlsForTrimming(); | 602 LoadUrlsForTrimming(); |
603 IncrementalTrimReferrers(true); // Do everything now. | 603 IncrementalTrimReferrers(true); // Do everything now. |
604 } | 604 } |
605 | 605 |
606 void Predictor::SerializeReferrers(ListValue* referral_list) { | 606 void Predictor::SerializeReferrers(ListValue* referral_list) { |
607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
608 referral_list->Clear(); | 608 referral_list->Clear(); |
609 referral_list->Append(new base::FundamentalValue(PREDICTOR_REFERRER_VERSION)); | 609 referral_list->Append(base::NumberValue::New(PREDICTOR_REFERRER_VERSION)); |
610 for (Referrers::const_iterator it = referrers_.begin(); | 610 for (Referrers::const_iterator it = referrers_.begin(); |
611 it != referrers_.end(); ++it) { | 611 it != referrers_.end(); ++it) { |
612 // Serialize the list of subresource names. | 612 // Serialize the list of subresource names. |
613 Value* subresource_list(it->second.Serialize()); | 613 Value* subresource_list(it->second.Serialize()); |
614 | 614 |
615 // Create a list for each referer. | 615 // Create a list for each referer. |
616 ListValue* motivator(new ListValue); | 616 ListValue* motivator(new ListValue); |
617 motivator->Append(new StringValue(it->first.spec())); | 617 motivator->Append(base::StringValue::New(it->first.spec())); |
618 motivator->Append(subresource_list); | 618 motivator->Append(subresource_list); |
619 | 619 |
620 referral_list->Append(motivator); | 620 referral_list->Append(motivator); |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
624 void Predictor::DeserializeReferrers(const ListValue& referral_list) { | 624 void Predictor::DeserializeReferrers(const ListValue& referral_list) { |
625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
626 int format_version = -1; | 626 int format_version = -1; |
627 if (referral_list.GetSize() > 0 && | 627 if (referral_list.GetSize() > 0 && |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 // If we omit a port, it will default to 80 or 443 as appropriate. | 763 // If we omit a port, it will default to 80 or 443 as appropriate. |
764 std::string colon_plus_port; | 764 std::string colon_plus_port; |
765 if (url.has_port()) | 765 if (url.has_port()) |
766 colon_plus_port = ":" + url.port(); | 766 colon_plus_port = ":" + url.port(); |
767 | 767 |
768 return GURL(scheme + "://" + url.host() + colon_plus_port); | 768 return GURL(scheme + "://" + url.host() + colon_plus_port); |
769 } | 769 } |
770 | 770 |
771 | 771 |
772 } // namespace chrome_browser_net | 772 } // namespace chrome_browser_net |
OLD | NEW |