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

Side by Side Diff: chrome/browser/extensions/webstore_data_fetcher.h

Issue 2655823002: Include referrer chain with inline install requests. (Closed)
Patch Set: Cleanup. Created 3 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/gtest_prod_util.h"
Devlin 2017/01/30 17:24:48 needed?
robertshield 2017/01/31 02:48:14 Done.
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace base { 17 namespace base {
17 class Value; 18 class Value;
18 } 19 }
19 20
20 namespace net { 21 namespace net {
21 class URLFetcher; 22 class URLFetcher;
22 class URLRequestContextGetter; 23 class URLRequestContextGetter;
23 } 24 }
24 25
25 namespace extensions { 26 namespace extensions {
26 27
27 class WebstoreDataFetcherDelegate; 28 class WebstoreDataFetcherDelegate;
28 29
29 // WebstoreDataFetcher fetches web store data and parses it into a 30 // WebstoreDataFetcher fetches web store data and parses it into a
30 // DictionaryValue. 31 // DictionaryValue.
31 class WebstoreDataFetcher : public base::SupportsWeakPtr<WebstoreDataFetcher>, 32 class WebstoreDataFetcher : public base::SupportsWeakPtr<WebstoreDataFetcher>,
32 public net::URLFetcherDelegate { 33 public net::URLFetcherDelegate {
33 public: 34 public:
34 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate, 35 WebstoreDataFetcher(WebstoreDataFetcherDelegate* delegate,
35 net::URLRequestContextGetter* request_context, 36 net::URLRequestContextGetter* request_context,
36 const GURL& referrer_url, 37 const GURL& referrer_url,
37 const std::string webstore_item_id); 38 const std::string webstore_item_id);
38 ~WebstoreDataFetcher() override; 39 ~WebstoreDataFetcher() override;
39 40
41 // Makes this request use a POST instead of GET, and sends |json| in the
42 // body of the request. If |json| is empty, this is a no-op.
43 void SetJsonPostData(const std::string& json);
44
40 void Start(); 45 void Start();
41 46
42 void set_max_auto_retries(int max_retries) { 47 void set_max_auto_retries(int max_retries) {
43 max_auto_retries_ = max_retries; 48 max_auto_retries_ = max_retries;
44 } 49 }
45 50
46 private: 51 private:
47 void OnJsonParseSuccess(std::unique_ptr<base::Value> parsed_json); 52 void OnJsonParseSuccess(std::unique_ptr<base::Value> parsed_json);
48 void OnJsonParseFailure(const std::string& error); 53 void OnJsonParseFailure(const std::string& error);
49 54
50 // net::URLFetcherDelegate overrides: 55 // net::URLFetcherDelegate overrides:
51 void OnURLFetchComplete(const net::URLFetcher* source) override; 56 void OnURLFetchComplete(const net::URLFetcher* source) override;
52 57
53 WebstoreDataFetcherDelegate* delegate_; 58 WebstoreDataFetcherDelegate* delegate_;
54 net::URLRequestContextGetter* request_context_; 59 net::URLRequestContextGetter* request_context_;
55 GURL referrer_url_; 60 GURL referrer_url_;
56 std::string id_; 61 std::string id_;
62 std::string json_post_data_;
57 63
58 // For fetching webstore JSON data. 64 // For fetching webstore JSON data.
59 std::unique_ptr<net::URLFetcher> webstore_data_url_fetcher_; 65 std::unique_ptr<net::URLFetcher> webstore_data_url_fetcher_;
60 66
61 // Maximum auto retry times on server 5xx error or ERR_NETWORK_CHANGED. 67 // Maximum auto retry times on server 5xx error or ERR_NETWORK_CHANGED.
62 // Default is 0 which means to use the URLFetcher default behavior. 68 // Default is 0 which means to use the URLFetcher default behavior.
63 int max_auto_retries_; 69 int max_auto_retries_;
64 70
65 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher); 71 DISALLOW_COPY_AND_ASSIGN(WebstoreDataFetcher);
66 }; 72 };
67 73
68 } // namespace extensions 74 } // namespace extensions
69 75
70 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_ 76 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_DATA_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698