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

Side by Side Diff: chrome/browser/android/ntp/ntp_snippets_bridge.cc

Issue 2162533002: Adding a request counter to the snippets fetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@traffic-monitor
Patch Set: Bernhard's comments Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ntp/ntp_snippets_bridge.h" 5 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/callback_android.h" 9 #include "base/android/callback_android.h"
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } // namespace 46 } // namespace
47 47
48 static jlong Init(JNIEnv* env, 48 static jlong Init(JNIEnv* env,
49 const JavaParamRef<jobject>& obj, 49 const JavaParamRef<jobject>& obj,
50 const JavaParamRef<jobject>& j_profile) { 50 const JavaParamRef<jobject>& j_profile) {
51 NTPSnippetsBridge* snippets_bridge = new NTPSnippetsBridge(env, j_profile); 51 NTPSnippetsBridge* snippets_bridge = new NTPSnippetsBridge(env, j_profile);
52 return reinterpret_cast<intptr_t>(snippets_bridge); 52 return reinterpret_cast<intptr_t>(snippets_bridge);
53 } 53 }
54 54
55 static void FetchSnippets(JNIEnv* env, 55 static void FetchSnippets(JNIEnv* env,
56 const JavaParamRef<jclass>& caller) { 56 const JavaParamRef<jclass>& caller,
57 jboolean j_force_request) {
57 Profile* profile = ProfileManager::GetLastUsedProfile(); 58 Profile* profile = ProfileManager::GetLastUsedProfile();
58 NTPSnippetsServiceFactory::GetForProfile(profile)->FetchSnippets(); 59 NTPSnippetsServiceFactory::GetForProfile(profile)->FetchSnippets(
60 j_force_request);
59 } 61 }
60 62
61 // Reschedules the fetching of snippets. Used to support different fetching 63 // Reschedules the fetching of snippets. Used to support different fetching
62 // intervals for different times of day. 64 // intervals for different times of day.
63 static void RescheduleFetching(JNIEnv* env, 65 static void RescheduleFetching(JNIEnv* env,
64 const JavaParamRef<jclass>& caller) { 66 const JavaParamRef<jclass>& caller) {
65 Profile* profile = ProfileManager::GetLastUsedProfile(); 67 Profile* profile = ProfileManager::GetLastUsedProfile();
66 NTPSnippetsServiceFactory::GetForProfile(profile)->RescheduleFetching(); 68 NTPSnippetsServiceFactory::GetForProfile(profile)->RescheduleFetching();
67 } 69 }
68 70
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (!image.IsEmpty()) 193 if (!image.IsEmpty())
192 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); 194 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap());
193 195
194 base::android::RunCallbackAndroid(callback, j_bitmap); 196 base::android::RunCallbackAndroid(callback, j_bitmap);
195 } 197 }
196 198
197 // static 199 // static
198 bool NTPSnippetsBridge::Register(JNIEnv* env) { 200 bool NTPSnippetsBridge::Register(JNIEnv* env) {
199 return RegisterNativesImpl(env); 201 return RegisterNativesImpl(env);
200 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698