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

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

Issue 2889453003: [Offline Prefetech] Send GetOperationReqest to the server (Closed)
Patch Set: Address 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/prefetch_request_fetcher.h
diff --git a/components/offline_pages/core/prefetch/prefetch_request_fetcher.h b/components/offline_pages/core/prefetch/prefetch_request_fetcher.h
index 09c543ab0bbfd0352ad4bda17e6792013e2043f6..c24515ecf9487da4e9dbadcc48a0cc20a9cdb085 100644
--- a/components/offline_pages/core/prefetch/prefetch_request_fetcher.h
+++ b/components/offline_pages/core/prefetch/prefetch_request_fetcher.h
@@ -11,28 +11,44 @@
#include "components/offline_pages/core/prefetch/prefetch_types.h"
#include "net/url_request/url_fetcher_delegate.h"
-class GURL;
namespace net {
class URLRequestContextGetter;
}
namespace offline_pages {
+// Asynchronously fetches the offline prefetch related data from the server.
class PrefetchRequestFetcher : public net::URLFetcherDelegate {
public:
using FinishedCallback = base::Callback<void(PrefetchRequestStatus status,
const std::string& data)>;
- PrefetchRequestFetcher(const GURL& url,
- const std::string& message,
- net::URLRequestContextGetter* request_context_getter,
- const FinishedCallback& callback);
+ // Creates a fetcher that will sends a GET request to the server.
+ static std::unique_ptr<PrefetchRequestFetcher> CreateForGet(
+ const std::string& url_path,
+ net::URLRequestContextGetter* request_context_getter,
+ const FinishedCallback& callback);
+
+ // Creates a fetcher that will sends a POST request to the server.
+ static std::unique_ptr<PrefetchRequestFetcher> CreateForPost(
+ const std::string& url_path,
+ const std::string& message,
+ net::URLRequestContextGetter* request_context_getter,
+ const FinishedCallback& callback);
+
~PrefetchRequestFetcher() override;
// URLFetcherDelegate implementation.
void OnURLFetchComplete(const net::URLFetcher* source) override;
private:
+ // If |message| is empty, the GET request is sent. Otherwise, the POST request
+ // is sent with |message| as post data.
+ PrefetchRequestFetcher(const std::string& url_path,
+ const std::string& message,
+ net::URLRequestContextGetter* request_context_getter,
+ const FinishedCallback& callback);
+
PrefetchRequestStatus ParseResponse(const net::URLFetcher* source,
std::string* data);

Powered by Google App Engine
This is Rietveld 408576698