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

Side by Side Diff: chrome/browser/file_select_helper.cc

Issue 2545723005: Use TaskScheduler instead of WorkerPool in file_select_helper.cc. (Closed)
Patch Set: may block Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_select_helper.h" 5 #include "chrome/browser/file_select_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/worker_pool.h" 19 #include "base/task_scheduler/post_task.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/platform_util.h" 22 #include "chrome/browser/platform_util.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/chrome_select_file_policy.h" 27 #include "chrome/browser/ui/chrome_select_file_policy.h"
28 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 void FileSelectHelper::StartNewEnumeration(const base::FilePath& path, 244 void FileSelectHelper::StartNewEnumeration(const base::FilePath& path,
245 int request_id, 245 int request_id,
246 RenderViewHost* render_view_host) { 246 RenderViewHost* render_view_host) {
247 std::unique_ptr<ActiveDirectoryEnumeration> entry( 247 std::unique_ptr<ActiveDirectoryEnumeration> entry(
248 new ActiveDirectoryEnumeration); 248 new ActiveDirectoryEnumeration);
249 entry->rvh_ = render_view_host; 249 entry->rvh_ = render_view_host;
250 entry->delegate_.reset(new DirectoryListerDispatchDelegate(this, request_id)); 250 entry->delegate_.reset(new DirectoryListerDispatchDelegate(this, request_id));
251 entry->lister_.reset(new net::DirectoryLister( 251 entry->lister_.reset(new net::DirectoryLister(
252 path, net::DirectoryLister::NO_SORT_RECURSIVE, entry->delegate_.get())); 252 path, net::DirectoryLister::NO_SORT_RECURSIVE, entry->delegate_.get()));
253 if (!entry->lister_->Start(base::WorkerPool::GetTaskRunner(true).get())) { 253 if (!entry->lister_->Start(
254 base::CreateTaskRunnerWithTraits(
255 base::TaskTraits()
256 .WithShutdownBehavior(
257 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
258 .MayBlock())
259 .get())) {
254 if (request_id == kFileSelectEnumerationId) 260 if (request_id == kFileSelectEnumerationId)
255 FileSelectionCanceled(NULL); 261 FileSelectionCanceled(NULL);
256 else 262 else
257 render_view_host->DirectoryEnumerationFinished(request_id, 263 render_view_host->DirectoryEnumerationFinished(request_id,
258 entry->results_); 264 entry->results_);
259 } else { 265 } else {
260 directory_enumerations_[request_id] = entry.release(); 266 directory_enumerations_[request_id] = entry.release();
261 } 267 }
262 } 268 }
263 269
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 703
698 // static 704 // static
699 base::FilePath FileSelectHelper::GetSanitizedFileName( 705 base::FilePath FileSelectHelper::GetSanitizedFileName(
700 const base::FilePath& suggested_filename) { 706 const base::FilePath& suggested_filename) {
701 if (suggested_filename.empty()) 707 if (suggested_filename.empty())
702 return base::FilePath(); 708 return base::FilePath();
703 return net::GenerateFileName( 709 return net::GenerateFileName(
704 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), 710 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(),
705 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 711 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
706 } 712 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698