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/traffic_annotation/network_traffic_annotation.h" | 20 #include "net/traffic_annotation/network_traffic_annotation.h" |
20 #include "net/url_request/url_fetcher.h" | 21 #include "net/url_request/url_fetcher.h" |
21 #include "net/url_request/url_fetcher_delegate.h" | 22 #include "net/url_request/url_fetcher_delegate.h" |
(...skipping 12 matching lines...) Expand all Loading... |
34 return base::Bind(&UploadUserData::CreateUploadUserData, depth); | 35 return base::Bind(&UploadUserData::CreateUploadUserData, depth); |
35 } | 36 } |
36 | 37 |
37 static const void* const kUserDataKey; | 38 static const void* const kUserDataKey; |
38 | 39 |
39 int depth() const { return depth_; } | 40 int depth() const { return depth_; } |
40 | 41 |
41 private: | 42 private: |
42 UploadUserData(int depth) : depth_(depth) {} | 43 UploadUserData(int depth) : depth_(depth) {} |
43 | 44 |
44 static base::SupportsUserData::Data* CreateUploadUserData(int depth) { | 45 static std::unique_ptr<base::SupportsUserData::Data> CreateUploadUserData( |
45 return new UploadUserData(depth); | 46 int depth) { |
| 47 return base::WrapUnique(new UploadUserData(depth)); |
46 } | 48 } |
47 | 49 |
48 int depth_; | 50 int depth_; |
49 }; | 51 }; |
50 | 52 |
51 const void* const UploadUserData::kUserDataKey = | 53 const void* const UploadUserData::kUserDataKey = |
52 &UploadUserData::kUserDataKey; | 54 &UploadUserData::kUserDataKey; |
53 | 55 |
54 class DomainReliabilityUploaderImpl | 56 class DomainReliabilityUploaderImpl |
55 : public DomainReliabilityUploader, net::URLFetcherDelegate { | 57 : public DomainReliabilityUploader, net::URLFetcherDelegate { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 UploadUserData* data = static_cast<UploadUserData*>( | 226 UploadUserData* data = static_cast<UploadUserData*>( |
225 request.GetUserData(UploadUserData::kUserDataKey)); | 227 request.GetUserData(UploadUserData::kUserDataKey)); |
226 if (!data) | 228 if (!data) |
227 return 0; | 229 return 0; |
228 return data->depth(); | 230 return data->depth(); |
229 } | 231 } |
230 | 232 |
231 void DomainReliabilityUploader::Shutdown() {} | 233 void DomainReliabilityUploader::Shutdown() {} |
232 | 234 |
233 } // namespace domain_reliability | 235 } // namespace domain_reliability |
OLD | NEW |