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

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

Issue 2682523002: Use TaskScheduler in directory_lister.cc. (Closed)
Patch Set: remove ScopedTaskScheduler from TokenBindingURLRequestTest Created 3 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
« no previous file with comments | « no previous file | net/base/directory_lister.h » ('j') | 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/task_scheduler/post_task.h"
20 #include "build/build_config.h" 19 #include "build/build_config.h"
21 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/platform_util.h" 21 #include "chrome/browser/platform_util.h"
23 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/chrome_select_file_policy.h" 26 #include "chrome/browser/ui/chrome_select_file_policy.h"
28 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
29 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 242
244 void FileSelectHelper::StartNewEnumeration(const base::FilePath& path, 243 void FileSelectHelper::StartNewEnumeration(const base::FilePath& path,
245 int request_id, 244 int request_id,
246 RenderViewHost* render_view_host) { 245 RenderViewHost* render_view_host) {
247 std::unique_ptr<ActiveDirectoryEnumeration> entry( 246 std::unique_ptr<ActiveDirectoryEnumeration> entry(
248 new ActiveDirectoryEnumeration); 247 new ActiveDirectoryEnumeration);
249 entry->rvh_ = render_view_host; 248 entry->rvh_ = render_view_host;
250 entry->delegate_.reset(new DirectoryListerDispatchDelegate(this, request_id)); 249 entry->delegate_.reset(new DirectoryListerDispatchDelegate(this, request_id));
251 entry->lister_.reset(new net::DirectoryLister( 250 entry->lister_.reset(new net::DirectoryLister(
252 path, net::DirectoryLister::NO_SORT_RECURSIVE, entry->delegate_.get())); 251 path, net::DirectoryLister::NO_SORT_RECURSIVE, entry->delegate_.get()));
253 if (!entry->lister_->Start( 252 entry->lister_->Start();
254 base::CreateTaskRunnerWithTraits( 253 directory_enumerations_[request_id] = entry.release();
255 base::TaskTraits()
256 .WithShutdownBehavior(
257 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
258 .MayBlock())
259 .get())) {
260 if (request_id == kFileSelectEnumerationId)
261 FileSelectionCanceled(NULL);
262 else
263 render_view_host->DirectoryEnumerationFinished(request_id,
264 entry->results_);
265 } else {
266 directory_enumerations_[request_id] = entry.release();
267 }
268 } 254 }
269 255
270 void FileSelectHelper::OnListFile( 256 void FileSelectHelper::OnListFile(
271 int id, 257 int id,
272 const net::DirectoryLister::DirectoryListerData& data) { 258 const net::DirectoryLister::DirectoryListerData& data) {
273 ActiveDirectoryEnumeration* entry = directory_enumerations_[id]; 259 ActiveDirectoryEnumeration* entry = directory_enumerations_[id];
274 260
275 // Directory upload only cares about files. 261 // Directory upload only cares about files.
276 if (data.info.IsDirectory()) 262 if (data.info.IsDirectory())
277 return; 263 return;
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 692
707 // static 693 // static
708 base::FilePath FileSelectHelper::GetSanitizedFileName( 694 base::FilePath FileSelectHelper::GetSanitizedFileName(
709 const base::FilePath& suggested_filename) { 695 const base::FilePath& suggested_filename) {
710 if (suggested_filename.empty()) 696 if (suggested_filename.empty())
711 return base::FilePath(); 697 return base::FilePath();
712 return net::GenerateFileName( 698 return net::GenerateFileName(
713 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), 699 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(),
714 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 700 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
715 } 701 }
OLDNEW
« no previous file with comments | « no previous file | net/base/directory_lister.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698