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

Side by Side Diff: components/offline_pages/core/prefetch/prefetch_request_fetcher.h

Issue 2889453003: [Offline Prefetech] Send GetOperationReqest to the server (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "components/offline_pages/core/prefetch/prefetch_types.h" 11 #include "components/offline_pages/core/prefetch/prefetch_types.h"
12 #include "net/url_request/url_fetcher_delegate.h" 12 #include "net/url_request/url_fetcher_delegate.h"
13 13
14 class GURL;
15 namespace net { 14 namespace net {
16 class URLRequestContextGetter; 15 class URLRequestContextGetter;
17 } 16 }
18 17
19 namespace offline_pages { 18 namespace offline_pages {
20 19
20 // Asynchronously fetches the offline prefetch related data from the server.
21 class PrefetchRequestFetcher : public net::URLFetcherDelegate { 21 class PrefetchRequestFetcher : public net::URLFetcherDelegate {
22 public: 22 public:
23 using FinishedCallback = base::Callback<void(PrefetchRequestStatus status, 23 using FinishedCallback = base::Callback<void(PrefetchRequestStatus status,
24 const std::string& data)>; 24 const std::string& data)>;
25 25
26 PrefetchRequestFetcher(const GURL& url, 26 // If |message| is empty, the GET request is sent. Otherwise, the POST request
27 // is sent with |message| as post data.
28 PrefetchRequestFetcher(const std::string& url_path,
dewittj 2017/05/16 18:30:20 Can you make two constructors, one that is for pos
jianli 2017/05/16 22:44:40 Changed to 2 static creator methods since their na
27 const std::string& message, 29 const std::string& message,
28 net::URLRequestContextGetter* request_context_getter, 30 net::URLRequestContextGetter* request_context_getter,
29 const FinishedCallback& callback); 31 const FinishedCallback& callback);
30 ~PrefetchRequestFetcher() override; 32 ~PrefetchRequestFetcher() override;
31 33
32 // URLFetcherDelegate implementation. 34 // URLFetcherDelegate implementation.
33 void OnURLFetchComplete(const net::URLFetcher* source) override; 35 void OnURLFetchComplete(const net::URLFetcher* source) override;
34 36
35 private: 37 private:
36 PrefetchRequestStatus ParseResponse(const net::URLFetcher* source, 38 PrefetchRequestStatus ParseResponse(const net::URLFetcher* source,
37 std::string* data); 39 std::string* data);
38 40
39 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 41 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
40 std::unique_ptr<net::URLFetcher> url_fetcher_; 42 std::unique_ptr<net::URLFetcher> url_fetcher_;
41 FinishedCallback callback_; 43 FinishedCallback callback_;
42 44
43 DISALLOW_COPY_AND_ASSIGN(PrefetchRequestFetcher); 45 DISALLOW_COPY_AND_ASSIGN(PrefetchRequestFetcher);
44 }; 46 };
45 47
46 } // namespace offline_pages 48 } // namespace offline_pages
47 49
48 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_ 50 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_REQUEST_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698