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

Side by Side Diff: components/domain_reliability/uploader.cc

Issue 2815913005: Switch to using scoped_ptr with UserData (Closed)
Patch Set: nico Created 3 years, 8 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 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698