Commit f3261005 authored by Tobias Sargeant's avatar Tobias Sargeant Committed by Commit Bot

[weblayer] Add weblayer specific paths to path service.

This also adds the definition of the os-specific path beneath which
crash dumps should be stored.

Change-Id: I500d9e0fef2844550c62dfe6a7e71bddf786f2ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879261
Commit-Queue: Tobias Sargeant <tobiasjs@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709841}
parent b5662383
......@@ -67,6 +67,8 @@ jumbo_static_library("weblayer_lib") {
"common/content_client_impl.h",
"common/features.cc",
"common/features.h",
"common/weblayer_paths.cc",
"common/weblayer_paths.h",
"public/browser_controller.h",
"public/browser_observer.h",
"public/download_delegate.h",
......
......@@ -22,6 +22,7 @@
#include "ui/base/ui_base_paths.h"
#include "weblayer/browser/content_browser_client_impl.h"
#include "weblayer/common/content_client_impl.h"
#include "weblayer/common/weblayer_paths.h"
#include "weblayer/utility/content_utility_client_impl.h"
#if defined(OS_ANDROID)
......@@ -128,6 +129,7 @@ bool ContentMainDelegateImpl::BasicStartupComplete(int* exit_code) {
content_client_ = std::make_unique<ContentClientImpl>();
SetContentClient(content_client_.get());
RegisterPathProvider();
return false;
}
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "weblayer/common/weblayer_paths.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "build/build_config.h"
#if defined(OS_ANDROID)
#include "base/android/path_utils.h"
#include "base/base_paths_android.h"
#endif
namespace weblayer {
bool PathProvider(int key, base::FilePath* result) {
base::FilePath cur;
switch (key) {
#if defined(OS_ANDROID)
case weblayer::DIR_CRASH_DUMPS:
if (!base::android::GetCacheDirectory(&cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("Crashpad"));
if (!base::PathExists(cur))
base::CreateDirectory(cur);
*result = cur;
return true;
#endif
default:
return false;
}
}
void RegisterPathProvider() {
base::PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
}
} // namespace weblayer
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBLAYER_COMMON_WEBLAYER_PATHS_H_
#define WEBLAYER_COMMON_WEBLAYER_PATHS_H_
#include "build/build_config.h"
// This file declares path keys for weblayer. These can be used with
// the PathService to access various special directories and files.
namespace weblayer {
enum {
PATH_START = 1000,
#if defined(OS_ANDROID)
DIR_CRASH_DUMPS = PATH_START, // Directory where crash dumps are written.
#endif
PATH_END
};
// Call once to register the provider for the path keys defined above.
void RegisterPathProvider();
} // namespace weblayer
#endif // WEBLAYER_COMMON_WEBLAYER_PATHS_H_
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