-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use 'cobalt' instead of 'content_shell' for logging and paths.
This changes the paths and the default log file to 'cobalt' instead of 'content_shell'. With this PR, the local storage for the `cobalt` target on linux will be `~/.config/cobalt` b/374191454
- Loading branch information
Showing
6 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2021 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "cobalt/cobalt_paths.h" | ||
|
||
#include "base/base_paths.h" | ||
#include "base/environment.h" | ||
#include "base/files/file_util.h" | ||
#include "base/path_service.h" | ||
#include "base/threading/thread_restrictions.h" | ||
#include "build/build_config.h" | ||
|
||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) | ||
#include "base/nix/xdg_util.h" | ||
#endif | ||
|
||
namespace cobalt { | ||
|
||
namespace { | ||
|
||
bool GetDefaultUserDataDirectory(base::FilePath* result) { | ||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) | ||
std::unique_ptr<base::Environment> env(base::Environment::Create()); | ||
base::FilePath config_dir(base::nix::GetXDGDirectory( | ||
env.get(), base::nix::kXdgConfigHomeEnvVar, base::nix::kDotConfigDir)); | ||
*result = config_dir.Append("cobalt"); | ||
#elif BUILDFLAG(IS_ANDROID) | ||
CHECK(base::PathService::Get(base::DIR_ANDROID_APP_DATA, result)); | ||
*result = result->Append(FILE_PATH_LITERAL("cobalt")); | ||
#else | ||
NOTIMPLEMENTED(); | ||
return false; | ||
#endif | ||
return true; | ||
} | ||
|
||
} // namespace | ||
|
||
class CobaltPathProvider { | ||
public: | ||
static void CreateDir(const base::FilePath& path) { | ||
base::ScopedAllowBlocking allow_io; | ||
if (!base::PathExists(path)) { | ||
base::CreateDirectory(path); | ||
} | ||
} | ||
}; | ||
|
||
bool CobaltPathProvider(int key, base::FilePath* result) { | ||
base::FilePath cur; | ||
|
||
switch (key) { | ||
case SHELL_DIR_USER_DATA: { | ||
bool rv = GetDefaultUserDataDirectory(result); | ||
if (rv) { | ||
CobaltPathProvider::CreateDir(*result); | ||
} | ||
return rv; | ||
} | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
void RegisterCobaltPathProvider() { | ||
base::PathService::RegisterProvider(CobaltPathProvider, SHELL_PATH_START, | ||
SHELL_PATH_END); | ||
} | ||
|
||
} // namespace cobalt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2021 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CONTENT_SHELL_BROWSER_SHELL_PATHS_H_ | ||
#define CONTENT_SHELL_BROWSER_SHELL_PATHS_H_ | ||
|
||
#include "build/build_config.h" | ||
|
||
namespace cobalt { | ||
|
||
enum { | ||
SHELL_PATH_START = 12000, | ||
|
||
// Directory where user data can be written. | ||
SHELL_DIR_USER_DATA = SHELL_PATH_START, | ||
|
||
// TODO(jam): move from content/common since it's test only. | ||
// DIR_TEST_DATA, | ||
|
||
SHELL_PATH_END | ||
}; | ||
|
||
// Call once to register the provider for the path keys defined above. | ||
void RegisterCobaltPathProvider(); | ||
|
||
} // namespace cobalt | ||
|
||
#endif // CONTENT_SHELL_BROWSER_SHELL_PATHS_H_ |