0

mojo: Avoid #includes in foo.mojom-forward.h

This CL reduces pre-processed size of foo.mojom(-blink)-forward.h
including interfaces or structs significantly. For example,

  file_chooser.mojom-blink-forward.h: 1.66MB => 0.004MB

* mojo/public/cpp/bindings/*_forward.h
  New files.  They contain some forward declarations for
  mojo/public/cpp/bindings/.

* mojo/public/tools/bindings/generators/cpp_templates/module-forward.h.tmpl
  Include only *_forward.h and native_struct.mojom-forward.h.
  native_struct.mojom-forward.h is necessary for [native] structs.

* ipc/message_view.{h,cc}
  Move TakeHandles() implementation to message_view.cc in order to avoid
  instantiation of mojo::StructPtr<> in the header.

* Other files
  Add #includes or forward declarations which were included indirectly
  from mojo headers.


Change-Id: I08ac30fc40cb7af4ce248e8e9b5b1ff4fb55ed68
Bug: 862064
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768608
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690932}
This commit is contained in:
Kent Tamura
2019-08-27 23:43:59 +00:00
committed by Commit Bot
parent a5ebbe609d
commit f4476efcef
21 changed files with 91 additions and 26 deletions

@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/exo/surface.h"
#include "ui/aura/window.h"
#include "ui/aura/window_targeter.h"

@ -10,6 +10,7 @@
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chromeos/constants/chromeos_switches.h"
#include "ui/display/manager/display_layout_store.h"
#include "ui/display/manager/display_manager.h"

@ -10,6 +10,7 @@
#include "base/i18n/message_formatter.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h"

@ -18,6 +18,10 @@
#include "ui/base/material_design/material_design_controller_observer.h"
#include "ui/views/view.h"
namespace ui {
class MaterialDesignController;
}
class ToolbarView;
enum class InProductHelpFeature;

@ -6,6 +6,7 @@
#include "ash/drag_drop/drag_drop_controller.h"
#include "base/barrier_closure.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/exo/data_offer.h"
#include "components/exo/data_source.h"
#include "components/exo/seat.h"

@ -16,6 +16,7 @@
#include "base/synchronization/lock.h"
#include "content/common/child_process.mojom-forward.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/system/handle.h"
namespace content {

@ -15,6 +15,7 @@
#include <vector>
#include "base/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/supports_user_data.h"
#include "content/common/content_export.h"

@ -8,13 +8,23 @@
#include <memory>
#include <vector>
#include "base/callback.h"
#include "base/files/file.h"
#include "content/common/download/mhtml_file_writer.mojom-forward.h"
#include "mojo/public/cpp/system/data_pipe.h"
namespace base {
class TaskRunner;
}
namespace blink {
class WebThreadSafeData;
}
namespace mojo {
class SimpleWatcher;
}
namespace content {
// TODO(https://crbug.com/915966): This class needs unit tests.

@ -7,6 +7,7 @@
#include <utility>
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"

@ -29,4 +29,9 @@ MessageView::~MessageView() = default;
MessageView& MessageView::operator=(MessageView&&) = default;
base::Optional<std::vector<mojo::native::SerializedHandlePtr>>
MessageView::TakeHandles() {
return std::move(handles_);
}
} // namespace IPC

@ -40,9 +40,7 @@ class COMPONENT_EXPORT(IPC_MOJOM) MessageView {
mojo_base::BigBufferView TakeBufferView() { return std::move(buffer_view_); }
base::Optional<std::vector<mojo::native::SerializedHandlePtr>> TakeHandles() {
return std::move(handles_);
}
base::Optional<std::vector<mojo::native::SerializedHandlePtr>> TakeHandles();
private:
mojo_base::BigBufferView buffer_view_;

@ -38,6 +38,7 @@ component("bindings_base") {
"clone_traits.h",
"connection_group.cc",
"connection_group.h",
"deprecated_interface_types_forward.h",
"disconnect_reason.h",
"enum_traits.h",
"equals_traits.h",
@ -98,6 +99,7 @@ component("bindings_base") {
"string_traits.h",
"string_traits_stl.h",
"string_traits_string_piece.h",
"struct_forward.h",
"struct_ptr.h",
"struct_traits.h",
"type_converter.h",

@ -0,0 +1,35 @@
// 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 MOJO_PUBLIC_CPP_BINDINGS_DEPRECATED_INTERFACE_TYPES_FORWARD_H_
#define MOJO_PUBLIC_CPP_BINDINGS_DEPRECATED_INTERFACE_TYPES_FORWARD_H_
// Forward declarations which foo.mojom-forward.h requires.
namespace mojo {
template <typename Interface>
class InterfacePtr;
template <typename Interface>
class InterfacePtrInfo;
template <typename Interface>
class InterfaceRequest;
template <typename Interface>
class AssociatedInterfacePtr;
template <typename Interface>
class AssociatedInterfacePtrInfo;
template <typename Interface>
class AssociatedInterfaceRequest;
template <typename InterfacePtrType>
class ThreadSafeInterfacePtrBase;
template <typename Interface>
using ThreadSafeAssociatedInterfacePtr =
ThreadSafeInterfacePtrBase<AssociatedInterfacePtr<Interface>>;
template <typename Interface>
using ThreadSafeInterfacePtr =
ThreadSafeInterfacePtrBase<InterfacePtr<Interface>>;
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_DEPRECATED_INTERFACE_TYPES_FORWARD_H_

@ -0,0 +1,18 @@
// 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 MOJO_PUBLIC_CPP_BINDINGS_STRUCT_FORWARD_H_
#define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_FORWARD_H_
// Forward declarations which foo.mojom-forward.h requires.
namespace mojo {
template <typename S>
class StructPtr;
template <typename S>
class InlinedStructPtr;
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_FORWARD_H_

@ -17,6 +17,7 @@
#include "base/threading/sequenced_task_runner_handle.h"
#include "mojo/public/cpp/bindings/associated_group.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/deprecated_interface_types_forward.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
@ -395,14 +396,6 @@ class ThreadSafeInterfacePtrBase
DISALLOW_COPY_AND_ASSIGN(ThreadSafeInterfacePtrBase);
};
template <typename Interface>
using ThreadSafeAssociatedInterfacePtr =
ThreadSafeInterfacePtrBase<AssociatedInterfacePtr<Interface>>;
template <typename Interface>
using ThreadSafeInterfacePtr =
ThreadSafeInterfacePtrBase<InterfacePtr<Interface>>;
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_

@ -44,27 +44,15 @@ namespace {{variant}} {
{%- endif %}
{% if structs|length -%}
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_forward.h"
{%- endif %}
{% if not disallow_interfaces and interfaces|length -%}
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"
#include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h"
#include "mojo/public/cpp/bindings/deprecated_interface_types_forward.h"
{%- endif %}
{% if not disallow_native_types and structs|length %}
#include "mojo/public/cpp/bindings/lib/native_enum_serialization.h"
#include "mojo/public/cpp/bindings/lib/native_struct_serialization.h"
#include "mojo/public/interfaces/bindings/native_struct.mojom-forward.h"
{%- endif %}
{%- if export_header and module.constants|length %}

@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_CONTENT_INDEX_CONTENT_DESCRIPTION_TYPE_CONVERTER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_CONTENT_INDEX_CONTENT_DESCRIPTION_TYPE_CONVERTER_H_
#include "mojo/public/cpp/bindings/type_converter.h"
#include "third_party/blink/public/mojom/content_index/content_index.mojom-blink-forward.h"
#include "third_party/blink/renderer/modules/content_index/content_description.h"
#include "third_party/blink/renderer/modules/modules_export.h"

@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_NFC_NFC_TYPE_CONVERTERS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_NFC_NFC_TYPE_CONVERTERS_H_
#include "mojo/public/cpp/bindings/type_converter.h"
#include "services/device/public/mojom/nfc.mojom-blink-forward.h"
#include "third_party/blink/renderer/modules/nfc/nfc_constants.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"

@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/stl_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/gfx/animation/linear_animation.h"
#include "ui/gfx/animation/tween.h"
#include "ui/message_center/message_center.h"

@ -5,6 +5,7 @@
#include "ui/message_center/views/slide_out_controller.h"
#include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/transform.h"

@ -5,6 +5,7 @@
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
#include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/transient_window_client.h"