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

Side by Side Diff: chrome/browser/ui/webui/options/certificate_manager_handler.cc

Issue 137263007: Move CancelableTaskTracker to //base/task/CancelableTaskTracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move to base/task/cancelable_task_tracker* Created 6 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/options/certificate_manager_handler.h" 5 #include "chrome/browser/ui/webui/options/certificate_manager_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 : public base::RefCountedThreadSafe<FileAccessProvider> { 198 : public base::RefCountedThreadSafe<FileAccessProvider> {
199 public: 199 public:
200 // The first parameter is 0 on success or errno on failure. The second 200 // The first parameter is 0 on success or errno on failure. The second
201 // parameter is read result. 201 // parameter is read result.
202 typedef base::Callback<void(const int*, const std::string*)> ReadCallback; 202 typedef base::Callback<void(const int*, const std::string*)> ReadCallback;
203 203
204 // The first parameter is 0 on success or errno on failure. The second 204 // The first parameter is 0 on success or errno on failure. The second
205 // parameter is the number of bytes written on success. 205 // parameter is the number of bytes written on success.
206 typedef base::Callback<void(const int*, const int*)> WriteCallback; 206 typedef base::Callback<void(const int*, const int*)> WriteCallback;
207 207
208 CancelableTaskTracker::TaskId StartRead(const base::FilePath& path, 208 base::CancelableTaskTracker::TaskId StartRead(
209 const ReadCallback& callback, 209 const base::FilePath& path,
210 CancelableTaskTracker* tracker); 210 const ReadCallback& callback,
211 CancelableTaskTracker::TaskId StartWrite(const base::FilePath& path, 211 base::CancelableTaskTracker* tracker);
212 const std::string& data, 212 base::CancelableTaskTracker::TaskId StartWrite(
213 const WriteCallback& callback, 213 const base::FilePath& path,
214 CancelableTaskTracker* tracker); 214 const std::string& data,
215 const WriteCallback& callback,
216 base::CancelableTaskTracker* tracker);
215 217
216 private: 218 private:
217 friend class base::RefCountedThreadSafe<FileAccessProvider>; 219 friend class base::RefCountedThreadSafe<FileAccessProvider>;
218 virtual ~FileAccessProvider() {} 220 virtual ~FileAccessProvider() {}
219 221
220 // Reads file at |path|. |saved_errno| is 0 on success or errno on failure. 222 // Reads file at |path|. |saved_errno| is 0 on success or errno on failure.
221 // When success, |data| has file content. 223 // When success, |data| has file content.
222 void DoRead(const base::FilePath& path, 224 void DoRead(const base::FilePath& path,
223 int* saved_errno, 225 int* saved_errno,
224 std::string* data); 226 std::string* data);
225 // Writes data to file at |path|. |saved_errno| is 0 on success or errno on 227 // Writes data to file at |path|. |saved_errno| is 0 on success or errno on
226 // failure. When success, |bytes_written| has number of bytes written. 228 // failure. When success, |bytes_written| has number of bytes written.
227 void DoWrite(const base::FilePath& path, 229 void DoWrite(const base::FilePath& path,
228 const std::string& data, 230 const std::string& data,
229 int* saved_errno, 231 int* saved_errno,
230 int* bytes_written); 232 int* bytes_written);
231 }; 233 };
232 234
233 CancelableTaskTracker::TaskId FileAccessProvider::StartRead( 235 base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead(
234 const base::FilePath& path, 236 const base::FilePath& path,
235 const ReadCallback& callback, 237 const ReadCallback& callback,
236 CancelableTaskTracker* tracker) { 238 base::CancelableTaskTracker* tracker) {
237 // Owned by reply callback posted below. 239 // Owned by reply callback posted below.
238 int* saved_errno = new int(0); 240 int* saved_errno = new int(0);
239 std::string* data = new std::string(); 241 std::string* data = new std::string();
240 242
241 // Post task to file thread to read file. 243 // Post task to file thread to read file.
242 return tracker->PostTaskAndReply( 244 return tracker->PostTaskAndReply(
243 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), 245 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(),
244 FROM_HERE, 246 FROM_HERE,
245 base::Bind(&FileAccessProvider::DoRead, this, path, saved_errno, data), 247 base::Bind(&FileAccessProvider::DoRead, this, path, saved_errno, data),
246 base::Bind(callback, base::Owned(saved_errno), base::Owned(data))); 248 base::Bind(callback, base::Owned(saved_errno), base::Owned(data)));
247 } 249 }
248 250
249 CancelableTaskTracker::TaskId FileAccessProvider::StartWrite( 251 base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite(
250 const base::FilePath& path, 252 const base::FilePath& path,
251 const std::string& data, 253 const std::string& data,
252 const WriteCallback& callback, 254 const WriteCallback& callback,
253 CancelableTaskTracker* tracker) { 255 base::CancelableTaskTracker* tracker) {
254 // Owned by reply callback posted below. 256 // Owned by reply callback posted below.
255 int* saved_errno = new int(0); 257 int* saved_errno = new int(0);
256 int* bytes_written = new int(0); 258 int* bytes_written = new int(0);
257 259
258 // Post task to file thread to write file. 260 // Post task to file thread to write file.
259 return tracker->PostTaskAndReply( 261 return tracker->PostTaskAndReply(
260 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), 262 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(),
261 FROM_HERE, 263 FROM_HERE,
262 base::Bind(&FileAccessProvider::DoWrite, 264 base::Bind(&FileAccessProvider::DoWrite,
263 this, 265 this,
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 title_value, 1128 title_value,
1127 error_value, 1129 error_value,
1128 cert_error_list); 1130 cert_error_list);
1129 } 1131 }
1130 1132
1131 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { 1133 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const {
1132 return web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(); 1134 return web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow();
1133 } 1135 }
1134 1136
1135 } // namespace options 1137 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/certificate_manager_handler.h ('k') | chrome/browser/ui/webui/version_handler_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698