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

Side by Side Diff: chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.cc

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix another failure missed by my regex Created 5 years, 7 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 "chrome/browser/supervised_user/experimental/supervised_user_blacklist_ downloader.h" 5 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist_ downloader.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "net/base/load_flags.h" 11 #include "net/base/load_flags.h"
12 #include "net/http/http_status_code.h" 12 #include "net/http/http_status_code.h"
13 #include "net/url_request/url_fetcher.h" 13 #include "net/url_request/url_fetcher.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 using content::BrowserThread; 16 using content::BrowserThread;
17 using net::URLFetcher; 17 using net::URLFetcher;
18 18
19 const int kNumRetries = 1; 19 const int kNumRetries = 1;
20 20
21 SupervisedUserBlacklistDownloader::SupervisedUserBlacklistDownloader( 21 SupervisedUserBlacklistDownloader::SupervisedUserBlacklistDownloader(
22 const GURL& url, 22 const GURL& url,
23 const base::FilePath& path, 23 const base::FilePath& path,
24 net::URLRequestContextGetter* request_context, 24 net::URLRequestContextGetter* request_context,
25 const DownloadFinishedCallback& callback) 25 const DownloadFinishedCallback& callback)
26 : callback_(callback), 26 : callback_(callback),
27 fetcher_(URLFetcher::Create(url, URLFetcher::GET, this)), 27 fetcher_(URLFetcher::Create(url, URLFetcher::GET, this).Pass()),
28 weak_ptr_factory_(this) { 28 weak_ptr_factory_(this) {
29 fetcher_->SetRequestContext(request_context); 29 fetcher_->SetRequestContext(request_context);
30 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 30 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
31 net::LOAD_DO_NOT_SAVE_COOKIES); 31 net::LOAD_DO_NOT_SAVE_COOKIES);
32 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); 32 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries);
33 fetcher_->SaveResponseToFileAtPath( 33 fetcher_->SaveResponseToFileAtPath(
34 path, 34 path,
35 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); 35 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
36 36
37 base::PostTaskAndReplyWithResult( 37 base::PostTaskAndReplyWithResult(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 void SupervisedUserBlacklistDownloader::OnFileExistsCheckDone(bool exists) { 72 void SupervisedUserBlacklistDownloader::OnFileExistsCheckDone(bool exists) {
73 if (exists) { 73 if (exists) {
74 // TODO(treib): Figure out a strategy for updating the file. 74 // TODO(treib): Figure out a strategy for updating the file.
75 callback_.Run(true); 75 callback_.Run(true);
76 } else { 76 } else {
77 fetcher_->Start(); 77 fetcher_->Start();
78 } 78 }
79 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698