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

Unified Diff: chrome/browser/android/offline_pages/evaluation/offline_page_evaluation_bridge.h

Issue 2378803003: [Offline Pages] Added OfflinePageEvaluationBridge for testing. (Closed)
Patch Set: Fixing build. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/evaluation/offline_page_evaluation_bridge.h
diff --git a/chrome/browser/android/offline_pages/evaluation/offline_page_evaluation_bridge.h b/chrome/browser/android/offline_pages/evaluation/offline_page_evaluation_bridge.h
new file mode 100644
index 0000000000000000000000000000000000000000..72d0561b441d6b15eeb5cec5583041722e70cfa2
--- /dev/null
+++ b/chrome/browser/android/offline_pages/evaluation/offline_page_evaluation_bridge.h
@@ -0,0 +1,93 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_BRIDGE_H_
+#define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_BRIDGE_H_
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_weak_ref.h"
+#include "base/android/scoped_java_ref.h"
+#include "base/macros.h"
+#include "components/offline_pages/background/request_coordinator.h"
+#include "components/offline_pages/background/request_notifier.h"
+#include "components/offline_pages/offline_page_model.h"
+
+namespace content {
+class BrowserContext;
+}
+
+namespace offline_pages {
+
+struct OfflinePageItem;
+
+namespace android {
+
+/**
+ * Bridge for exposing native implementation which are used by evaluation.
+ */
+class OfflinePageEvaluationBridge : public OfflinePageModel::Observer,
+ public RequestCoordinator::Observer {
+ public:
+ static bool Register(JNIEnv* env);
+
+ OfflinePageEvaluationBridge(JNIEnv* env,
+ content::BrowserContext* browser_context,
+ OfflinePageModel* offline_page_model,
+ RequestCoordinator* request_coordinator);
+
+ ~OfflinePageEvaluationBridge() override;
+
+ // OfflinePageModel::Observer implementation.
+ void OfflinePageModelLoaded(OfflinePageModel* model) override;
+ void OfflinePageModelChanged(OfflinePageModel* model) override;
+ void OfflinePageDeleted(int64_t offline_id,
+ const ClientId& client_id) override;
+
+ // RequestCoordinator::Observer implementation.
+ void OnAdded(const SavePageRequest& request) override;
+ void OnCompleted(const SavePageRequest& request,
+ RequestNotifier::BackgroundSavePageResult status) override;
+ void OnChanged(const SavePageRequest& request) override;
+
+ void GetAllPages(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ const base::android::JavaParamRef<jobject>& j_result_obj,
+ const base::android::JavaParamRef<jobject>& j_callback_obj);
+
+ void PushRequestProcessing(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ const base::android::JavaParamRef<jobject>& j_callback_obj);
+
+ void SavePageLater(JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ const base::android::JavaParamRef<jstring>& url,
+ const base::android::JavaParamRef<jstring>& j_namespace,
+ const base::android::JavaParamRef<jstring>& j_client_id,
+ jboolean user_requested);
+
+ base::android::ScopedJavaGlobalRef<jobject> java_ref() { return java_ref_; }
+
+ private:
+ void NotifyIfDoneLoading() const;
+
+ base::android::ScopedJavaLocalRef<jobject> CreateClientId(
+ JNIEnv* env,
+ const ClientId& clientId) const;
+
+ base::android::ScopedJavaGlobalRef<jobject> java_ref_;
+ // Not owned.
+ content::BrowserContext* browser_context_;
+ // Not owned.
+ OfflinePageModel* offline_page_model_;
+ // Not owned.
+ RequestCoordinator* request_coordinator_;
+
+ DISALLOW_COPY_AND_ASSIGN(OfflinePageEvaluationBridge);
+};
+
+} // namespace android
+} // namespace offline_pages
+
+#endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_BRIDGE_H_

Powered by Google App Engine
This is Rietveld 408576698