Move away from BrowserThread::FILE
* Migrate TtsPlatformImplLinux away from using BrowserThread::FILE. https://chromium-review.googlesource.com/c/chromium/src/+/570022 * Move PdfConverter off the FILE thread. https://chromium-review.googlesource.com/c/chromium/src/+/592393 * https://chromium.googlesource.com/chromium/src/+/master/docs/task_scheduler_migration.md
This commit is contained in:
parent
6d241e972b
commit
e3c580e905
6 changed files with 124 additions and 100 deletions
|
@ -16,6 +16,8 @@
|
|||
#include "atom/common/atom_constants.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/task_scheduler/post_task.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
|
@ -100,14 +102,14 @@ std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
|
|||
}
|
||||
|
||||
void WriteToFile(const base::FilePath& path, const std::string& content) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
||||
base::AssertBlockingAllowed();
|
||||
DCHECK(!path.empty());
|
||||
|
||||
base::WriteFile(path, content.data(), content.size());
|
||||
}
|
||||
|
||||
void AppendToFile(const base::FilePath& path, const std::string& content) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
||||
base::AssertBlockingAllowed();
|
||||
DCHECK(!path.empty());
|
||||
|
||||
base::AppendToFile(path, content.data(), content.size());
|
||||
|
@ -142,7 +144,9 @@ bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
|
|||
} // namespace
|
||||
|
||||
CommonWebContentsDelegate::CommonWebContentsDelegate()
|
||||
: devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {}
|
||||
: devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
|
||||
file_task_runner_(
|
||||
base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()})) {}
|
||||
|
||||
CommonWebContentsDelegate::~CommonWebContentsDelegate() {}
|
||||
|
||||
|
@ -309,11 +313,13 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(const std::string& url,
|
|||
}
|
||||
|
||||
saved_files_[url] = path;
|
||||
BrowserThread::PostTaskAndReply(
|
||||
BrowserThread::FILE, FROM_HERE,
|
||||
base::BindOnce(&WriteToFile, path, content),
|
||||
base::BindOnce(&CommonWebContentsDelegate::OnDevToolsSaveToFile,
|
||||
base::Unretained(this), url));
|
||||
// Notify DevTools.
|
||||
base::Value url_value(url);
|
||||
base::Value file_system_path_value(path.AsUTF8Unsafe());
|
||||
web_contents_->CallClientFunction("DevToolsAPI.savedURL", &url_value,
|
||||
&file_system_path_value, nullptr);
|
||||
file_task_runner_->PostTask(FROM_HERE,
|
||||
base::BindOnce(&WriteToFile, path, content));
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::DevToolsAppendToFile(
|
||||
|
@ -323,11 +329,12 @@ void CommonWebContentsDelegate::DevToolsAppendToFile(
|
|||
if (it == saved_files_.end())
|
||||
return;
|
||||
|
||||
BrowserThread::PostTaskAndReply(
|
||||
BrowserThread::FILE, FROM_HERE,
|
||||
base::BindOnce(&AppendToFile, it->second, content),
|
||||
base::BindOnce(&CommonWebContentsDelegate::OnDevToolsAppendToFile,
|
||||
base::Unretained(this), url));
|
||||
// Notify DevTools.
|
||||
base::Value url_value(url);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.appendedToURL", &url_value,
|
||||
nullptr, nullptr);
|
||||
file_task_runner_->PostTask(
|
||||
FROM_HERE, base::BindOnce(&AppendToFile, it->second, content));
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::DevToolsRequestFileSystems() {
|
||||
|
@ -455,20 +462,6 @@ void CommonWebContentsDelegate::DevToolsSearchInPath(
|
|||
base::Unretained(this), request_id, file_system_path));
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::OnDevToolsSaveToFile(const std::string& url) {
|
||||
// Notify DevTools.
|
||||
base::Value url_value(url);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.savedURL", &url_value, nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::OnDevToolsAppendToFile(const std::string& url) {
|
||||
// Notify DevTools.
|
||||
base::Value url_value(url);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.appendedToURL", &url_value,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
|
||||
int request_id,
|
||||
const std::string& file_system_path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue