Commit 5809d107 authored by Maciek Kumorek's avatar Maciek Kumorek Committed by Commit Bot

Create the scheduled tasks in a company branded folder.


Create the scheduled tasks grouped in a company branded folder.
E.g. Chrome updater scheduled tasks land under \\Google\GoogleUpdater.
The BRANDING file will be the only change required to avoid collisions
between scheduled task registered by the implementers of the new updater.

When the tasks are deleted, folders should be deleted as well,
assuming no other tasks or sub-folders are present.

Bug: 1047747
Change-Id: Id6f9833fdc32e4c0845faa1e5025d08c61dbcc29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036415
Commit-Queue: Maciek Kumorek <makumo@microsoft.com>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740355}
parent e67c2bec
......@@ -127,13 +127,6 @@ int Setup() {
std::make_unique<base::win::ScopedCOMInitializer>(
base::win::ScopedCOMInitializer::kMTA);
if (!TaskScheduler::Initialize()) {
LOG(ERROR) << "Failed to initialize the scheduler.";
return -1;
}
base::ScopedClosureRunner task_scheduler_terminate_caller(
base::BindOnce([]() { TaskScheduler::Terminate(); }));
base::FilePath temp_dir;
if (!base::GetTempDir(&temp_dir)) {
LOG(ERROR) << "GetTempDir failed.";
......
......@@ -14,7 +14,7 @@ namespace updater {
namespace {
constexpr base::char16 kTaskName[] = L"GoogleUpdaterUA";
constexpr base::char16 kTaskName[] = L"UpdateApps";
constexpr base::char16 kTaskDescription[] = L"Update all applications.";
} // namespace
......
......@@ -40,13 +40,6 @@ int Uninstall() {
std::make_unique<base::win::ScopedCOMInitializer>(
base::win::ScopedCOMInitializer::kMTA);
if (!TaskScheduler::Initialize()) {
LOG(ERROR) << "Failed to initialize the scheduler.";
return -1;
}
base::ScopedClosureRunner task_scheduler_terminate_caller(
base::BindOnce([]() { TaskScheduler::Terminate(); }));
updater::UnregisterUpdateAppsTask();
std::unique_ptr<WorkItemList> uninstall_list(WorkItem::CreateWorkItemList());
......
This diff is collapsed.
......@@ -85,14 +85,6 @@ class TaskScheduler {
uint32_t logon_type = 0;
};
// Control the lifespan of static data for the TaskScheduler. |Initialize|
// must be called before the first call to |CreateInstance|, and not other
// methods can be called after |Terminate| was called (unless |Initialize| is
// called again). |Initialize| can't be called out of balance with
// |Terminate|. |Terminate| can be called any number of times.
static bool Initialize();
static void Terminate();
static std::unique_ptr<TaskScheduler> CreateInstance();
virtual ~TaskScheduler() {}
......@@ -122,6 +114,9 @@ class TaskScheduler {
// encountered. On error, the struct is left unmodified.
virtual bool GetTaskInfo(const wchar_t* task_name, TaskInfo* info) = 0;
// Returns true if the task folder specified by |folder_name| exists.
virtual bool HasTaskFolder(const wchar_t* folder_name) = 0;
// Register the task to run the specified application and using the given
// |trigger_type|.
virtual bool RegisterTask(const wchar_t* task_name,
......
......@@ -22,6 +22,7 @@
#include "base/win/scoped_bstr.h"
#include "base/win/scoped_variant.h"
#include "base/win/windows_version.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/win/test/test_executables.h"
#include "chrome/updater/win/test/test_strings.h"
#include "chrome/updater/win/util.h"
......@@ -291,6 +292,9 @@ TEST_F(TaskSchedulerTests, GetTaskInfoNameAndDescription) {
EXPECT_EQ(kTaskDescription1, info.description);
EXPECT_EQ(kTaskName1, info.name);
EXPECT_TRUE(task_scheduler_->HasTaskFolder(
L"\\" COMPANY_SHORTNAME_STRING L"\\" PRODUCT_FULLNAME_STRING));
EXPECT_TRUE(task_scheduler_->DeleteTask(kTaskName1));
}
......
......@@ -24,9 +24,6 @@ int main(int argc, char** argv) {
bool success = updater::InitializeCOMSecurity();
DCHECK(success) << "InitializeCOMSecurity() failed.";
success = updater::TaskScheduler::Initialize();
DCHECK(success) << "TaskScheduler::Initialize() failed.";
// Some tests will fail if two tests try to launch test_process.exe
// simultaneously, so run the tests serially. This will still shard them and
// distribute the shards to different swarming bots, but tests will run
......@@ -39,7 +36,5 @@ int main(int argc, char** argv) {
false,
base::BindOnce(&base::TestSuite::Run, base::Unretained(&test_suite)));
updater::TaskScheduler::Terminate();
return result;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment