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

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

Issue 252613002: Domain Reliability: More security review. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/sparse_histogram.h" 8 #include "base/metrics/sparse_histogram.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
11 #include "net/url_request/url_fetcher.h" 11 #include "net/url_request/url_fetcher.h"
12 #include "net/url_request/url_fetcher_delegate.h" 12 #include "net/url_request/url_fetcher_delegate.h"
13 #include "net/url_request/url_request_context_getter.h" 13 #include "net/url_request/url_request_context_getter.h"
14 14
15 namespace domain_reliability { 15 namespace domain_reliability {
16 16
17 namespace { 17 namespace {
18 18
19 class DomainReliabilityUploaderImpl 19 class DomainReliabilityUploaderImpl
20 : public DomainReliabilityUploader, net::URLFetcherDelegate { 20 : public DomainReliabilityUploader, net::URLFetcherDelegate {
Ryan Sleevi 2014/04/26 02:37:39 "git cl format" should clean this up for you, as i
Deprecated (see juliatuttle) 2014/04/28 22:01:13 Done.
21 public: 21 public:
22 DomainReliabilityUploaderImpl( 22 DomainReliabilityUploaderImpl(
23 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) 23 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter)
Ryan Sleevi 2014/04/26 02:37:39 const scoped_refptr<...>&
Deprecated (see juliatuttle) 2014/04/28 22:01:13 Done.
24 : url_request_context_getter_(url_request_context_getter) {} 24 : url_request_context_getter_(url_request_context_getter) {}
25 25
26 virtual ~DomainReliabilityUploaderImpl() { 26 virtual ~DomainReliabilityUploaderImpl() {
27 // Delete any in-flight URLFetchers. 27 // Delete any in-flight URLFetchers.
28 STLDeleteContainerPairFirstPointers( 28 STLDeleteContainerPairFirstPointers(
29 upload_callbacks_.begin(), upload_callbacks_.end()); 29 upload_callbacks_.begin(), upload_callbacks_.end());
30 } 30 }
31 31
32 // DomainReliabilityUploader implementation: 32 // DomainReliabilityUploader implementation:
33 virtual void UploadReport( 33 virtual void UploadReport(
(...skipping 24 matching lines...) Expand all
58 DCHECK(callback_it != upload_callbacks_.end()); 58 DCHECK(callback_it != upload_callbacks_.end());
59 59
60 VLOG(1) << "Upload finished with " << fetcher->GetResponseCode(); 60 VLOG(1) << "Upload finished with " << fetcher->GetResponseCode();
61 61
62 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.UploadResponseCode", 62 UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.UploadResponseCode",
63 fetcher->GetResponseCode()); 63 fetcher->GetResponseCode());
64 64
65 bool success = fetcher->GetResponseCode() == 200; 65 bool success = fetcher->GetResponseCode() == 200;
66 callback_it->second.Run(success); 66 callback_it->second.Run(success);
67 67
68 delete callback_it->first; 68 delete callback_it->first;
Ryan Sleevi 2014/04/26 02:37:39 You don't have to de-constify this? (See line 74)
Deprecated (see juliatuttle) 2014/04/28 22:01:13 Apparently not! Deleting a const pointer seems to
69 upload_callbacks_.erase(callback_it); 69 upload_callbacks_.erase(callback_it);
70 } 70 }
71 71
72 private: 72 private:
73 using DomainReliabilityUploader::UploadCallback; 73 using DomainReliabilityUploader::UploadCallback;
74 typedef std::map<const net::URLFetcher*, UploadCallback> UploadCallbackMap; 74 typedef std::map<const net::URLFetcher*, UploadCallback> UploadCallbackMap;
75 75
76 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 76 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
77 UploadCallbackMap upload_callbacks_; 77 UploadCallbackMap upload_callbacks_;
78 }; 78 };
79 79
80 } // namespace 80 } // namespace
81 81
82 DomainReliabilityUploader::DomainReliabilityUploader() {} 82 DomainReliabilityUploader::DomainReliabilityUploader() {}
83
84 DomainReliabilityUploader::~DomainReliabilityUploader() {} 83 DomainReliabilityUploader::~DomainReliabilityUploader() {}
85 84
86 // static 85 // static
87 scoped_ptr<DomainReliabilityUploader> DomainReliabilityUploader::Create( 86 scoped_ptr<DomainReliabilityUploader> DomainReliabilityUploader::Create(
88 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) { 87 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) {
89 return scoped_ptr<DomainReliabilityUploader>( 88 return scoped_ptr<DomainReliabilityUploader>(
90 new DomainReliabilityUploaderImpl(url_request_context_getter)); 89 new DomainReliabilityUploaderImpl(url_request_context_getter));
91 } 90 }
92 91
93 } // namespace domain_reliability 92 } // namespace domain_reliability
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698