Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/browser/android/most_visited_sites.cc

Issue 1551033002: Convert Pass()→std::move() in //chrome (Android edition) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enable RVO by making types match Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/android/most_visited_sites.h" 5 #include "chrome/browser/android/most_visited_sites.h"
6 6
7 #include <utility>
8
7 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
11 #include "base/callback.h" 13 #include "base/callback.h"
12 #include "base/command_line.h" 14 #include "base/command_line.h"
13 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
15 #include "base/metrics/sparse_histogram.h" 17 #include "base/metrics/sparse_histogram.h"
16 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }; 88 };
87 89
88 scoped_ptr<SkBitmap> MaybeFetchLocalThumbnail( 90 scoped_ptr<SkBitmap> MaybeFetchLocalThumbnail(
89 const GURL& url, 91 const GURL& url,
90 const scoped_refptr<TopSites>& top_sites) { 92 const scoped_refptr<TopSites>& top_sites) {
91 DCHECK_CURRENTLY_ON(BrowserThread::DB); 93 DCHECK_CURRENTLY_ON(BrowserThread::DB);
92 scoped_refptr<base::RefCountedMemory> image; 94 scoped_refptr<base::RefCountedMemory> image;
93 scoped_ptr<SkBitmap> bitmap; 95 scoped_ptr<SkBitmap> bitmap;
94 if (top_sites && top_sites->GetPageThumbnail(url, false, &image)) 96 if (top_sites && top_sites->GetPageThumbnail(url, false, &image))
95 bitmap.reset(gfx::JPEGCodec::Decode(image->front(), image->size())); 97 bitmap.reset(gfx::JPEGCodec::Decode(image->front(), image->size()));
96 return bitmap.Pass(); 98 return bitmap;
97 } 99 }
98 100
99 // Log an event for a given |histogram| at a given element |position|. This 101 // Log an event for a given |histogram| at a given element |position|. This
100 // routine exists because regular histogram macros are cached thus can't be used 102 // routine exists because regular histogram macros are cached thus can't be used
101 // if the name of the histogram will change at a given call site. 103 // if the name of the histogram will change at a given call site.
102 void LogHistogramEvent(const std::string& histogram, 104 void LogHistogramEvent(const std::string& histogram,
103 int position, 105 int position,
104 int num_sites) { 106 int num_sites) {
105 base::HistogramBase* counter = base::LinearHistogram::FactoryGet( 107 base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
106 histogram, 108 histogram,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 326 }
325 } 327 }
326 if (mv_source_ == SUGGESTIONS_SERVICE) { 328 if (mv_source_ == SUGGESTIONS_SERVICE) {
327 return suggestions_service->GetPageThumbnail( 329 return suggestions_service->GetPageThumbnail(
328 url, base::Bind(&MostVisitedSites::OnObtainedThumbnail, 330 url, base::Bind(&MostVisitedSites::OnObtainedThumbnail,
329 weak_ptr_factory_.GetWeakPtr(), false, 331 weak_ptr_factory_.GetWeakPtr(), false,
330 base::Passed(&j_callback))); 332 base::Passed(&j_callback)));
331 } 333 }
332 } 334 }
333 } 335 }
334 OnObtainedThumbnail(true, j_callback.Pass(), url, bitmap.get()); 336 OnObtainedThumbnail(true, std::move(j_callback), url, bitmap.get());
335 } 337 }
336 338
337 void MostVisitedSites::OnObtainedThumbnail( 339 void MostVisitedSites::OnObtainedThumbnail(
338 bool is_local_thumbnail, 340 bool is_local_thumbnail,
339 scoped_ptr<ScopedJavaGlobalRef<jobject>> j_callback, 341 scoped_ptr<ScopedJavaGlobalRef<jobject>> j_callback,
340 const GURL& url, 342 const GURL& url,
341 const SkBitmap* bitmap) { 343 const SkBitmap* bitmap) {
342 DCHECK_CURRENTLY_ON(BrowserThread::UI); 344 DCHECK_CURRENTLY_ON(BrowserThread::UI);
343 JNIEnv* env = AttachCurrentThread(); 345 JNIEnv* env = AttachCurrentThread();
344 ScopedJavaLocalRef<jobject> j_bitmap; 346 ScopedJavaLocalRef<jobject> j_bitmap;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 personal_suggestions, &merged_suggestions, old_sites_url, old_sites_host); 583 personal_suggestions, &merged_suggestions, old_sites_url, old_sites_host);
582 // Insert popular suggestions if they existed previously. 584 // Insert popular suggestions if they existed previously.
583 std::vector<size_t> new_popular_suggestions = InsertMatchingSuggestions( 585 std::vector<size_t> new_popular_suggestions = InsertMatchingSuggestions(
584 popular_suggestions, &merged_suggestions, old_sites_url, old_sites_host); 586 popular_suggestions, &merged_suggestions, old_sites_url, old_sites_host);
585 // Insert leftover personal suggestions. 587 // Insert leftover personal suggestions.
586 size_t filled_so_far = InsertAllSuggestions( 588 size_t filled_so_far = InsertAllSuggestions(
587 0, new_personal_suggestions, personal_suggestions, &merged_suggestions); 589 0, new_personal_suggestions, personal_suggestions, &merged_suggestions);
588 // Insert leftover popular suggestions. 590 // Insert leftover popular suggestions.
589 InsertAllSuggestions(filled_so_far, new_popular_suggestions, 591 InsertAllSuggestions(filled_so_far, new_popular_suggestions,
590 popular_suggestions, &merged_suggestions); 592 popular_suggestions, &merged_suggestions);
591 return merged_suggestions.Pass(); 593 return merged_suggestions;
592 } 594 }
593 595
594 void MostVisitedSites::GetPreviousNTPSites( 596 void MostVisitedSites::GetPreviousNTPSites(
595 size_t num_tiles, 597 size_t num_tiles,
596 std::vector<std::string>* old_sites_url, 598 std::vector<std::string>* old_sites_url,
597 std::vector<bool>* old_sites_is_personal) const { 599 std::vector<bool>* old_sites_is_personal) const {
598 const PrefService* prefs = profile_->GetPrefs(); 600 const PrefService* prefs = profile_->GetPrefs();
599 const base::ListValue* url_list = prefs->GetList(prefs::kNTPSuggestionsURL); 601 const base::ListValue* url_list = prefs->GetList(prefs::kNTPSuggestionsURL);
600 const base::ListValue* source_list = 602 const base::ListValue* source_list =
601 prefs->GetList(prefs::kNTPSuggestionsIsPersonal); 603 prefs->GetList(prefs::kNTPSuggestionsIsPersonal);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 758 }
757 } 759 }
758 760
759 static jlong Init(JNIEnv* env, 761 static jlong Init(JNIEnv* env,
760 const JavaParamRef<jobject>& obj, 762 const JavaParamRef<jobject>& obj,
761 const JavaParamRef<jobject>& jprofile) { 763 const JavaParamRef<jobject>& jprofile) {
762 MostVisitedSites* most_visited_sites = 764 MostVisitedSites* most_visited_sites =
763 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); 765 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile));
764 return reinterpret_cast<intptr_t>(most_visited_sites); 766 return reinterpret_cast<intptr_t>(most_visited_sites);
765 } 767 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698