| OLD | NEW |
| 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_LOCAL_DISCOVERY_PRIVET_URL_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_URL_FETCHER_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_URL_FETCHER_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_URL_FETCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void SaveResponseToFile(); | 96 void SaveResponseToFile(); |
| 97 | 97 |
| 98 void Start(); | 98 void Start(); |
| 99 | 99 |
| 100 void SetUploadData(const std::string& upload_content_type, | 100 void SetUploadData(const std::string& upload_content_type, |
| 101 const std::string& upload_data); | 101 const std::string& upload_data); |
| 102 | 102 |
| 103 void SetUploadFilePath(const std::string& upload_content_type, | 103 void SetUploadFilePath(const std::string& upload_content_type, |
| 104 const base::FilePath& upload_file_path); | 104 const base::FilePath& upload_file_path); |
| 105 | 105 |
| 106 const GURL& url() const { return url_fetcher_->GetOriginalURL(); } | 106 const GURL& url() const { |
| 107 int response_code() const { return url_fetcher_->GetResponseCode(); } | 107 return url_fetcher_ ? url_fetcher_->GetOriginalURL() : url_; |
| 108 } |
| 109 int response_code() const { |
| 110 return url_fetcher_ ? url_fetcher_->GetResponseCode() : -1; |
| 111 } |
| 108 | 112 |
| 109 private: | 113 private: |
| 110 void OnURLFetchCompleteParseData(const net::URLFetcher* source); | 114 void OnURLFetchCompleteParseData(const net::URLFetcher* source); |
| 111 bool OnURLFetchCompleteDoNotParseData(const net::URLFetcher* source); | 115 bool OnURLFetchCompleteDoNotParseData(const net::URLFetcher* source); |
| 112 | 116 |
| 113 std::string GetHostString(); // Get string representing the host. | 117 std::string GetHostString(); // Get string representing the host. |
| 114 std::string GetPrivetAccessToken(); | 118 std::string GetPrivetAccessToken(); |
| 115 void Try(); | 119 void Try(); |
| 116 void ScheduleRetry(int timeout_seconds); | 120 void ScheduleRetry(int timeout_seconds); |
| 117 bool PrivetErrorTransient(const std::string& error); | 121 bool PrivetErrorTransient(const std::string& error); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 139 base::FilePath upload_file_path_; | 143 base::FilePath upload_file_path_; |
| 140 scoped_ptr<net::URLFetcher> url_fetcher_; | 144 scoped_ptr<net::URLFetcher> url_fetcher_; |
| 141 | 145 |
| 142 base::WeakPtrFactory<PrivetURLFetcher> weak_factory_; | 146 base::WeakPtrFactory<PrivetURLFetcher> weak_factory_; |
| 143 DISALLOW_COPY_AND_ASSIGN(PrivetURLFetcher); | 147 DISALLOW_COPY_AND_ASSIGN(PrivetURLFetcher); |
| 144 }; | 148 }; |
| 145 | 149 |
| 146 } // namespace local_discovery | 150 } // namespace local_discovery |
| 147 | 151 |
| 148 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_URL_FETCHER_H_ | 152 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_URL_FETCHER_H_ |
| OLD | NEW |