| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/extensions/api/dial/device_description_fetcher.h" | 5 #include "chrome/browser/media/router/discovery/dial/device_description_fetcher.
h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/extensions/api/dial/dial_device_data.h" | 9 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
| 14 #include "net/http/http_status_code.h" | 14 #include "net/http/http_status_code.h" |
| 15 #include "net/http/http_util.h" | 15 #include "net/http/http_util.h" |
| 16 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 18 | 18 |
| 19 using content::BrowserThread; | 19 using content::BrowserThread; |
| 20 | 20 |
| 21 constexpr char kApplicationUrlHeaderName[] = "Application-URL"; | 21 constexpr char kApplicationUrlHeaderName[] = "Application-URL"; |
| 22 constexpr int kMaxRetries = 3; | 22 constexpr int kMaxRetries = 3; |
| 23 // DIAL devices are unlikely to expose uPnP functions other than DIAL, so 256kb | 23 // DIAL devices are unlikely to expose uPnP functions other than DIAL, so 256kb |
| 24 // should be more than sufficient. | 24 // should be more than sufficient. |
| 25 constexpr int kMaxDescriptionSizeBytes = 262144; | 25 constexpr int kMaxDescriptionSizeBytes = 262144; |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace media_router { |
| 28 namespace api { | |
| 29 namespace dial { | |
| 30 | 28 |
| 31 DeviceDescriptionFetcher::DeviceDescriptionFetcher( | 29 DeviceDescriptionFetcher::DeviceDescriptionFetcher( |
| 32 const GURL& device_description_url, | 30 const GURL& device_description_url, |
| 33 net::URLRequestContextGetter* request_context, | 31 net::URLRequestContextGetter* request_context, |
| 34 base::OnceCallback<void(const DialDeviceDescriptionData&)> success_cb, | 32 base::OnceCallback<void(const DialDeviceDescriptionData&)> success_cb, |
| 35 base::OnceCallback<void(const std::string&)> error_cb) | 33 base::OnceCallback<void(const std::string&)> error_cb) |
| 36 : device_description_url_(device_description_url), | 34 : device_description_url_(device_description_url), |
| 37 request_context_(request_context), | 35 request_context_(request_context), |
| 38 success_cb_(std::move(success_cb)), | 36 success_cb_(std::move(success_cb)), |
| 39 error_cb_(std::move(error_cb)) { | 37 error_cb_(std::move(error_cb)) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 137 |
| 140 void DeviceDescriptionFetcher::OnURLFetchUploadProgress( | 138 void DeviceDescriptionFetcher::OnURLFetchUploadProgress( |
| 141 const net::URLFetcher* source, | 139 const net::URLFetcher* source, |
| 142 int64_t current, | 140 int64_t current, |
| 143 int64_t total) {} | 141 int64_t total) {} |
| 144 | 142 |
| 145 void DeviceDescriptionFetcher::ReportError(const std::string& message) { | 143 void DeviceDescriptionFetcher::ReportError(const std::string& message) { |
| 146 std::move(error_cb_).Run(message); | 144 std::move(error_cb_).Run(message); |
| 147 } | 145 } |
| 148 | 146 |
| 149 } // namespace dial | 147 } // namespace media_router |
| 150 } // namespace api | |
| 151 } // namespace extensions | |
| OLD | NEW |