| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/domain_reliability/uploader.h" | 5 #include "components/domain_reliability/uploader.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 14 #include "components/domain_reliability/util.h" | 15 #include "components/domain_reliability/util.h" |
| 15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 18 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
| 19 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
| 20 #include "net/url_request/url_fetcher_delegate.h" | 21 #include "net/url_request/url_fetcher_delegate.h" |
| 21 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 return base::Bind(&UploadUserData::CreateUploadUserData, depth); | 34 return base::Bind(&UploadUserData::CreateUploadUserData, depth); |
| 34 } | 35 } |
| 35 | 36 |
| 36 static const void* const kUserDataKey; | 37 static const void* const kUserDataKey; |
| 37 | 38 |
| 38 int depth() const { return depth_; } | 39 int depth() const { return depth_; } |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 UploadUserData(int depth) : depth_(depth) {} | 42 UploadUserData(int depth) : depth_(depth) {} |
| 42 | 43 |
| 43 static base::SupportsUserData::Data* CreateUploadUserData(int depth) { | 44 static std::unique_ptr<base::SupportsUserData::Data> CreateUploadUserData( |
| 44 return new UploadUserData(depth); | 45 int depth) { |
| 46 return base::WrapUnique(new UploadUserData(depth)); |
| 45 } | 47 } |
| 46 | 48 |
| 47 int depth_; | 49 int depth_; |
| 48 }; | 50 }; |
| 49 | 51 |
| 50 const void* const UploadUserData::kUserDataKey = | 52 const void* const UploadUserData::kUserDataKey = |
| 51 &UploadUserData::kUserDataKey; | 53 &UploadUserData::kUserDataKey; |
| 52 | 54 |
| 53 class DomainReliabilityUploaderImpl | 55 class DomainReliabilityUploaderImpl |
| 54 : public DomainReliabilityUploader, net::URLFetcherDelegate { | 56 : public DomainReliabilityUploader, net::URLFetcherDelegate { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 UploadUserData* data = static_cast<UploadUserData*>( | 199 UploadUserData* data = static_cast<UploadUserData*>( |
| 198 request.GetUserData(UploadUserData::kUserDataKey)); | 200 request.GetUserData(UploadUserData::kUserDataKey)); |
| 199 if (!data) | 201 if (!data) |
| 200 return 0; | 202 return 0; |
| 201 return data->depth(); | 203 return data->depth(); |
| 202 } | 204 } |
| 203 | 205 |
| 204 void DomainReliabilityUploader::Shutdown() {} | 206 void DomainReliabilityUploader::Shutdown() {} |
| 205 | 207 |
| 206 } // namespace domain_reliability | 208 } // namespace domain_reliability |
| OLD | NEW |