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

Unified Diff: components/offline_pages/core/prefetch/generate_page_bundle_request.h

Issue 2873383004: [Offline Prefetch] Send GeneratePageBundleRequest to the server (Closed)
Patch Set: Address more feedback Created 3 years, 7 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: components/offline_pages/core/prefetch/generate_page_bundle_request.h
diff --git a/components/offline_pages/core/prefetch/generate_page_bundle_request.h b/components/offline_pages/core/prefetch/generate_page_bundle_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..45350499792ce7586ff1dc4afc710e65d8b448a1
--- /dev/null
+++ b/components/offline_pages/core/prefetch/generate_page_bundle_request.h
@@ -0,0 +1,57 @@
+// Copyright 2017 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 COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_GENERATE_PAGE_BUNDLE_REQUEST_H_
+#define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_GENERATE_PAGE_BUNDLE_REQUEST_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "components/offline_pages/core/prefetch/prefetch_types.h"
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace offline_pages {
+
+class PrefetchRequestFetcher;
+namespace proto {
+class Any;
+class Operation;
+} // namespace proto
+
+class GeneratePageBundleRequest {
+ public:
+ using FinishedCallback =
+ base::Callback<void(PrefetchRequestStatus status,
+ const std::vector<RenderPageInfo>& pages)>;
+
+ GeneratePageBundleRequest(
+ const std::string& user_agent,
+ const std::string& gcm_registration_id,
+ int max_bundle_size_bytes,
+ const std::vector<std::string>& page_urls,
+ net::URLRequestContextGetter* request_context_getter,
+ const FinishedCallback& callback);
+ ~GeneratePageBundleRequest();
+
+ private:
+ void OnCompleted(PrefetchRequestStatus status, const std::string& data);
+ void ParseDoneOperationResponse(const proto::Operation& operation);
+ void ParsePendingOperationResponse(const proto::Operation& operation);
+ void ParseAnyData(const proto::Any& any_data);
+ void NotifyParsingFailure();
+
+ FinishedCallback callback_;
+ std::unique_ptr<PrefetchRequestFetcher> fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(GeneratePageBundleRequest);
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_GENERATE_PAGE_BUNDLE_REQUEST_H_

Powered by Google App Engine
This is Rietveld 408576698