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

Side by Side Diff: chrome/browser/safe_browsing/download_feedback.cc

Issue 17948002: Update Linux to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/safe_browsing/download_feedback.h" 5 #include "chrome/browser/safe_browsing/download_feedback.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util_proxy.h" 9 #include "base/files/file_util_proxy.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 DownloadFeedbackImpl::~DownloadFeedbackImpl() { 101 DownloadFeedbackImpl::~DownloadFeedbackImpl() {
102 DCHECK(CalledOnValidThread()); 102 DCHECK(CalledOnValidThread());
103 DVLOG(1) << "DownloadFeedback destructed " << this; 103 DVLOG(1) << "DownloadFeedback destructed " << this;
104 104
105 if (uploader_) { 105 if (uploader_) {
106 RecordUploadResult(UPLOAD_CANCELLED); 106 RecordUploadResult(UPLOAD_CANCELLED);
107 // Destroy the uploader before attempting to delete the file. 107 // Destroy the uploader before attempting to delete the file.
108 uploader_.reset(); 108 uploader_.reset();
109 } 109 }
110 110
111 base::FileUtilProxy::Delete(file_task_runner_, file_path_, false, 111 base::FileUtilProxy::Delete(file_task_runner_.get(),
112 file_path_,
113 false,
112 base::FileUtilProxy::StatusCallback()); 114 base::FileUtilProxy::StatusCallback());
113 } 115 }
114 116
115 void DownloadFeedbackImpl::Start(const base::Closure& finish_callback) { 117 void DownloadFeedbackImpl::Start(const base::Closure& finish_callback) {
116 DCHECK(CalledOnValidThread()); 118 DCHECK(CalledOnValidThread());
117 DCHECK(!uploader_); 119 DCHECK(!uploader_);
118 120
119 CommandLine* cmdline = CommandLine::ForCurrentProcess(); 121 CommandLine* cmdline = CommandLine::ForCurrentProcess();
120 122
121 ClientDownloadReport report_metadata; 123 ClientDownloadReport report_metadata;
122 124
123 bool r = report_metadata.mutable_download_request()->ParseFromString( 125 bool r = report_metadata.mutable_download_request()->ParseFromString(
124 ping_request_); 126 ping_request_);
125 DCHECK(r); 127 DCHECK(r);
126 r = report_metadata.mutable_download_response()->ParseFromString( 128 r = report_metadata.mutable_download_response()->ParseFromString(
127 ping_response_); 129 ping_response_);
128 DCHECK(r); 130 DCHECK(r);
129 file_size_ = report_metadata.download_request().length(); 131 file_size_ = report_metadata.download_request().length();
130 132
131 GURL url = GURL(cmdline->HasSwitch(switches::kSbDownloadFeedbackURL) ? 133 GURL url = GURL(cmdline->HasSwitch(switches::kSbDownloadFeedbackURL) ?
132 cmdline->GetSwitchValueASCII(switches::kSbDownloadFeedbackURL) : 134 cmdline->GetSwitchValueASCII(switches::kSbDownloadFeedbackURL) :
133 kSbDefaultFeedbackURL); 135 kSbDefaultFeedbackURL);
134 136
135 std::string metadata_string; 137 std::string metadata_string;
136 bool ok = report_metadata.SerializeToString(&metadata_string); 138 bool ok = report_metadata.SerializeToString(&metadata_string);
137 DCHECK(ok); 139 DCHECK(ok);
138 uploader_.reset(TwoPhaseUploader::Create( 140 uploader_.reset(
139 request_context_getter_, 141 TwoPhaseUploader::Create(request_context_getter_.get(),
140 file_task_runner_, 142 file_task_runner_.get(),
141 url, 143 url,
142 metadata_string, 144 metadata_string,
143 file_path_, 145 file_path_,
144 TwoPhaseUploader::ProgressCallback(), 146 TwoPhaseUploader::ProgressCallback(),
145 base::Bind(&DownloadFeedbackImpl::FinishedUpload, base::Unretained(this), 147 base::Bind(&DownloadFeedbackImpl::FinishedUpload,
146 finish_callback))); 148 base::Unretained(this),
149 finish_callback)));
147 uploader_->Start(); 150 uploader_->Start();
148 } 151 }
149 152
150 void DownloadFeedbackImpl::FinishedUpload(base::Closure finish_callback, 153 void DownloadFeedbackImpl::FinishedUpload(base::Closure finish_callback,
151 TwoPhaseUploader::State state, 154 TwoPhaseUploader::State state,
152 int net_error, 155 int net_error,
153 int response_code, 156 int response_code,
154 const std::string& response_data) { 157 const std::string& response_data) {
155 DCHECK(CalledOnValidThread()); 158 DCHECK(CalledOnValidThread());
156 DVLOG(1) << __FUNCTION__ << " " << state << " rlen=" << response_data.size(); 159 DVLOG(1) << __FUNCTION__ << " " << state << " rlen=" << response_data.size();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return new DownloadFeedbackImpl( 220 return new DownloadFeedbackImpl(
218 request_context_getter, file_task_runner, file_path, ping_request, 221 request_context_getter, file_task_runner, file_path, ping_request,
219 ping_response); 222 ping_response);
220 return DownloadFeedback::factory_->CreateDownloadFeedback( 223 return DownloadFeedback::factory_->CreateDownloadFeedback(
221 request_context_getter, file_task_runner, file_path, ping_request, 224 request_context_getter, file_task_runner, file_path, ping_request,
222 ping_response); 225 ping_response);
223 } 226 }
224 227
225 } // namespace safe_browsing 228 } // namespace safe_browsing
226 229
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698