Skip to content

Commit

Permalink
Reduce includes in extensions/common/constants.h.
Browse files Browse the repository at this point in the history
This file is includes in lots of places, so reducing its includes
reduces the amount of data necessary to build the chrome target by 1 GB.

1) Use mojom-forward.h instead of mojom.h
2) Removed unused ui/ include
3) Split `kMinimumSeverityToReportError` into its own header, since it
   needs base/logging.h, but is only used from 2 .cc files.
4) Tidy dependencies in extensions/common/BUILD.gn.

Then do IWYU or forward declare to fix the build, update DEPS, etc.

Bug: 242216
Change-Id: I3e71d1e0fd31731b5cf2b9e7a6130728ecacd2d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2849353
Reviewed-by: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: Sean Topping <seantopping@chromium.org>
Reviewed-by: David Bertoni <dbertoni@chromium.org>
Reviewed-by: Ben Wells <benwells@chromium.org>
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#877844}
  • Loading branch information
leizleiz authored and Chromium LUCI CQ committed Apr 30, 2021
1 parent c19b114 commit 7c1d96f
Show file tree
Hide file tree
Showing 33 changed files with 57 additions and 19 deletions.
1 change: 1 addition & 0 deletions apps/launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "base/task/thread_pool.h"
#include "build/chromeos_buildflags.h"
#include "components/services/app_service/public/cpp/file_handler_info.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
Expand Down
1 change: 1 addition & 0 deletions ash/dbus/url_handler_service_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "ash/public/cpp/new_window_delegate.h"
#include "base/bind.h"
#include "base/logging.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "extensions/common/constants.h"
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/apps/platform_apps/app_load_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "chrome/browser/apps/platform_apps/app_load_service_factory.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@
#include <string>
#include <vector>

#include "base/files/file.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
#include "chrome/browser/sharesheet/sharesheet_metrics.h"
#include "storage/browser/file_system/file_system_url.h"

class Profile;

namespace base {
class File;
}

namespace extensions {

namespace api {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "storage/common/file_system/file_system_types.h"
#include "storage/common/file_system/file_system_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkImage.h"
#include "ui/gfx/geometry/size.h"

namespace extensions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <memory>

#include "base/notreached.h"
#include "base/values.h"
#include "chrome/common/extensions/api/developer_private.h"
#include "extensions/browser/extension_error.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stddef.h>

#include "base/logging.h"
#include "base/notreached.h"
#include "base/stl_util.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/error_console/error_console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#include "components/version_info/version_info.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/feature_switch.h"
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/logging_constants.h"

namespace extensions {

Expand Down
1 change: 1 addition & 0 deletions chrome/browser/extensions/launch_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/pref_names.h"
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/app_list/app_list_controller_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"

namespace aura {
class Window;
} // namespace aura

class Profile;

// Interface to allow the view delegate to call out to whatever is controlling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>

#include "base/containers/flat_map.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "chrome/browser/ui/app_list/chrome_app_list_item.h"
#include "extensions/common/constants.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void TestAppListControllerDelegate::DismissView() {
did_dismiss_view_ = true;
}

gfx::NativeWindow TestAppListControllerDelegate::GetAppListWindow() {
aura::Window* TestAppListControllerDelegate::GetAppListWindow() {
return nullptr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestAppListControllerDelegate : public AppListControllerDelegate {

int64_t GetAppListDisplayId() override;
void DismissView() override;
gfx::NativeWindow GetAppListWindow() override;
aura::Window* GetAppListWindow() override;
bool IsAppPinned(const std::string& app_id) override;
void PinApp(const std::string& app_id) override;
void UnpinApp(const std::string& app_id) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "chrome/browser/web_applications/components/web_application_info.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "components/site_engagement/content/engagement_type.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "content/public/browser/notification_service.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/extensions/manifest_handlers/app_theme_color_info.h"
#include "chrome/common/extensions/manifest_handlers/linked_app_icons.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/unloaded_extension_reason.h"
Expand Down
1 change: 1 addition & 0 deletions chrome/common/extensions/DEPS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include_rules = [
"+ash/keyboard/ui/resources", # For virtual keyboard
"+components/policy/core/common",
"+components/services/app_service/public/mojom/types.mojom-shared.h",
"+extensions/grit",
"+extensions/strings/grit",
"+extensions/test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/values.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "testing/gtest/include/gtest/gtest.h"

typedef ChromeManifestTest ValidAppManifestTest;
Expand Down
1 change: 1 addition & 0 deletions chromecast/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ include_rules = [
"+components/profile_metrics",
"+components/proxy_config",
"+components/safe_search_api",
"+components/services/app_service/public/mojom/types.mojom-shared.h",
"+components/services/heap_profiling/heap_profiling_service.h",
"+components/services/heap_profiling/public/mojom",
"+components/services/heap_profiling/public/cpp/settings.h",
Expand Down
1 change: 1 addition & 0 deletions chromecast/browser/extensions/cast_extension_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "chromecast/browser/extensions/api/tts/tts_extension_api.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
Expand Down
1 change: 1 addition & 0 deletions extensions/browser/api/app_runtime/app_runtime_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "extensions/browser/entry_info.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_prefs.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/script_constants.h"
#include "extensions/common/user_script.h"
#include "third_party/skia/include/core/SkBitmap.h"

using content::WebContents;
using extensions::ExtensionResource;
Expand Down
1 change: 1 addition & 0 deletions extensions/browser/extension_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <string>

#include "base/callback.h"
#include "base/callback_list.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
Expand Down
1 change: 1 addition & 0 deletions extensions/browser/script_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "base/callback.h"
#include "base/optional.h"
#include "base/values.h"
#include "extensions/common/constants.h"
#include "extensions/common/mojom/action_type.mojom-shared.h"
#include "extensions/common/mojom/css_origin.mojom-shared.h"
Expand Down
8 changes: 4 additions & 4 deletions extensions/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ source_set("common_constants") {
sources = [
"constants.cc",
"constants.h",
"logging_constants.h",
]

deps = [
public_deps = [
"//base",
"//build:chromecast_buildflags",
"//build:chromeos_buildflags",
"//components/services/app_service/public/mojom",
"//components/version_info:channel",
"//ui/base",
]

deps = [ "//build:chromecast_buildflags" ]

configs += [
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
"//build/config/compiler:no_size_t_to_int_warning",
Expand Down
2 changes: 0 additions & 2 deletions extensions/common/constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ const char kPolicyBlockedScripting[] =

const int kContentVerificationDefaultBlockSize = 4096;

const logging::LogSeverity kMinimumSeverityToReportError = logging::LOG_WARNING;

const char kCastExtensionIdRelease[] = "pkedcjkdefgpdelpbcmbmeomcjbeemfm";
const char kCastExtensionIdDev[] = "enhhojjnijigcajfphajepfemndkmdlo";

Expand Down
6 changes: 1 addition & 5 deletions extensions/common/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include "base/files/file_path.h"
#include "base/strings/string_piece_forward.h"
#include "build/chromeos_buildflags.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
#include "ui/base/layout.h"
#include "components/services/app_service/public/mojom/types.mojom-forward.h"

namespace extensions {

Expand Down Expand Up @@ -297,9 +296,6 @@ extern const char kPolicyBlockedScripting[];
// The default block size for hashing used in content verification.
extern const int kContentVerificationDefaultBlockSize;

// The minimum severity of a log or error in order to report it to the browser.
extern const logging::LogSeverity kMinimumSeverityToReportError;

// IDs for the Media Router Component Extension.
extern const char kCastExtensionIdRelease[];
extern const char kCastExtensionIdDev[];
Expand Down
20 changes: 20 additions & 0 deletions extensions/common/logging_constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2021 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 EXTENSIONS_COMMON_LOGGING_CONSTANTS_H_
#define EXTENSIONS_COMMON_LOGGING_CONSTANTS_H_

#include "base/logging.h"

// Separate from constants.h to avoid pulling base/logging.h into many files.

namespace extension_misc {

// The minimum severity of a log or error in order to report it to the browser.
constexpr logging::LogSeverity kMinimumSeverityToReportError =
logging::LOG_WARNING;

} // namespace extension_misc

#endif // EXTENSIONS_COMMON_LOGGING_CONSTANTS_H_
2 changes: 1 addition & 1 deletion extensions/renderer/extensions_render_frame_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_messages.h"
#include "extensions/common/logging_constants.h"
#include "extensions/common/stack_frame.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_local_frame.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/path_service.h"
#include "base/strings/string_tokenizer.h"
#include "build/build_config.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "extensions/common/switches.h"
#include "extensions/shell/browser/shell_extension_system.h"

Expand Down
1 change: 1 addition & 0 deletions extensions/shell/browser/shell_extension_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/sequenced_task_runner.h"
#include "base/task_runner_util.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
Expand Down
1 change: 1 addition & 0 deletions extensions/shell/browser/shell_extension_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "components/services/app_service/public/mojom/types.mojom-shared.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
Expand Down

0 comments on commit 7c1d96f

Please sign in to comment.