| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_
BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_
BRIDGE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_
BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_
BRIDGE_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "components/offline_pages/background/request_coordinator.h" | 12 #include "components/offline_pages/background/request_coordinator.h" |
| 13 #include "components/offline_pages/background/request_notifier.h" | 13 #include "components/offline_pages/background/request_notifier.h" |
| 14 #include "components/offline_pages/offline_event_logger.h" |
| 14 #include "components/offline_pages/offline_page_model.h" | 15 #include "components/offline_pages/offline_page_model.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 class BrowserContext; | 18 class BrowserContext; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace offline_pages { | 21 namespace offline_pages { |
| 21 | 22 |
| 22 namespace android { | 23 namespace android { |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Bridge for exposing native implementation which are used by evaluation. | 26 * Bridge for exposing native implementation which are used by evaluation. |
| 26 */ | 27 */ |
| 27 class OfflinePageEvaluationBridge : public OfflinePageModel::Observer, | 28 class OfflinePageEvaluationBridge : public OfflinePageModel::Observer, |
| 28 public RequestCoordinator::Observer { | 29 public RequestCoordinator::Observer, |
| 30 public OfflineEventLogger::Client { |
| 29 public: | 31 public: |
| 30 static bool Register(JNIEnv* env); | 32 static bool Register(JNIEnv* env); |
| 31 static std::unique_ptr<KeyedService> GetTestingRequestCoordinator( | 33 static std::unique_ptr<KeyedService> GetTestingRequestCoordinator( |
| 32 content::BrowserContext* context); | 34 content::BrowserContext* context); |
| 33 | 35 |
| 34 OfflinePageEvaluationBridge(JNIEnv* env, | 36 OfflinePageEvaluationBridge(JNIEnv* env, |
| 35 content::BrowserContext* browser_context, | 37 content::BrowserContext* browser_context, |
| 36 OfflinePageModel* offline_page_model, | 38 OfflinePageModel* offline_page_model, |
| 37 RequestCoordinator* request_coordinator); | 39 RequestCoordinator* request_coordinator); |
| 38 | 40 |
| 39 ~OfflinePageEvaluationBridge() override; | 41 ~OfflinePageEvaluationBridge() override; |
| 40 | 42 |
| 41 // OfflinePageModel::Observer implementation. | 43 // OfflinePageModel::Observer implementation. |
| 42 void OfflinePageModelLoaded(OfflinePageModel* model) override; | 44 void OfflinePageModelLoaded(OfflinePageModel* model) override; |
| 43 void OfflinePageModelChanged(OfflinePageModel* model) override; | 45 void OfflinePageModelChanged(OfflinePageModel* model) override; |
| 44 void OfflinePageDeleted(int64_t offline_id, | 46 void OfflinePageDeleted(int64_t offline_id, |
| 45 const ClientId& client_id) override; | 47 const ClientId& client_id) override; |
| 46 | 48 |
| 47 // RequestCoordinator::Observer implementation. | 49 // RequestCoordinator::Observer implementation. |
| 48 void OnAdded(const SavePageRequest& request) override; | 50 void OnAdded(const SavePageRequest& request) override; |
| 49 void OnCompleted(const SavePageRequest& request, | 51 void OnCompleted(const SavePageRequest& request, |
| 50 RequestNotifier::BackgroundSavePageResult status) override; | 52 RequestNotifier::BackgroundSavePageResult status) override; |
| 51 void OnChanged(const SavePageRequest& request) override; | 53 void OnChanged(const SavePageRequest& request) override; |
| 52 | 54 |
| 55 // OfflineEventLogger::Client implementation. |
| 56 void CustomLog(const std::string& message) override; |
| 57 |
| 58 // Gets all pages in offline page model. |
| 53 void GetAllPages(JNIEnv* env, | 59 void GetAllPages(JNIEnv* env, |
| 54 const base::android::JavaParamRef<jobject>& obj, | 60 const base::android::JavaParamRef<jobject>& obj, |
| 55 const base::android::JavaParamRef<jobject>& j_result_obj, | 61 const base::android::JavaParamRef<jobject>& j_result_obj, |
| 56 const base::android::JavaParamRef<jobject>& j_callback_obj); | 62 const base::android::JavaParamRef<jobject>& j_callback_obj); |
| 57 | 63 |
| 58 // Return true if processing starts and callback is expected to be called. | 64 // Return true if processing starts and callback is expected to be called. |
| 59 // False otherwise. | 65 // False otherwise. |
| 60 bool PushRequestProcessing( | 66 bool PushRequestProcessing( |
| 61 JNIEnv* env, | 67 JNIEnv* env, |
| 62 const base::android::JavaParamRef<jobject>& obj, | 68 const base::android::JavaParamRef<jobject>& obj, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Not owned. | 105 // Not owned. |
| 100 RequestCoordinator* request_coordinator_; | 106 RequestCoordinator* request_coordinator_; |
| 101 | 107 |
| 102 DISALLOW_COPY_AND_ASSIGN(OfflinePageEvaluationBridge); | 108 DISALLOW_COPY_AND_ASSIGN(OfflinePageEvaluationBridge); |
| 103 }; | 109 }; |
| 104 | 110 |
| 105 } // namespace android | 111 } // namespace android |
| 106 } // namespace offline_pages | 112 } // namespace offline_pages |
| 107 | 113 |
| 108 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATI
ON_BRIDGE_H_ | 114 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATI
ON_BRIDGE_H_ |
| OLD | NEW |