From 130ad75c1b9408a91a8f86c320240e4137f35143 Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Fri, 13 Oct 2017 17:07:15 +0000 Subject: [PATCH] Export CanonOutputT template instantiations to avoid double definition. The double instantiations seem to happen because of virtual methods. If the class could lose be non-virtual, this could be fixed. However, this is blocking another CL and this fix is the optimal one with regards to time constraints. Bug: 747081 Change-Id: I5c2d2cc7a9e49266b25d2cd3d9835d0647e5438a Reviewed-on: https://chromium-review.googlesource.com/579211 Commit-Queue: Mounir Lamouri Reviewed-by: Jochen Eisinger Reviewed-by: Daniel Cheng Cr-Commit-Position: refs/heads/master@{#508734} --- base/BUILD.gn | 1 + {ipc => base}/export_template.h | 6 +++--- ipc/BUILD.gn | 1 - ipc/ipc_message_macros.h | 2 +- url/BUILD.gn | 1 + url/url_canon.cc | 12 ++++++++++++ url/url_canon.h | 6 ++++++ 7 files changed, 24 insertions(+), 5 deletions(-) rename {ipc => base}/export_template.h (98%) create mode 100644 url/url_canon.cc diff --git a/base/BUILD.gn b/base/BUILD.gn index 78c04dcfce80a7..a843c7ffbae007 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -294,6 +294,7 @@ component("base") { "environment.cc", "environment.h", "event_types.h", + "export_template.h", "feature_list.cc", "feature_list.h", "file_descriptor_posix.h", diff --git a/ipc/export_template.h b/base/export_template.h similarity index 98% rename from ipc/export_template.h rename to base/export_template.h index e743e1936f7a5a..aac8b7c7f122a0 100644 --- a/ipc/export_template.h +++ b/base/export_template.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef IPC_EXPORT_TEMPLATE_H_ -#define IPC_EXPORT_TEMPLATE_H_ +#ifndef BASE_EXPORT_TEMPLATE_H_ +#define BASE_EXPORT_TEMPLATE_H_ // Synopsis // @@ -160,4 +160,4 @@ EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport)); #undef EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT #undef EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK -#endif // IPC_EXPORT_TEMPLATE_H_ +#endif // BASE_EXPORT_TEMPLATE_H_ diff --git a/ipc/BUILD.gn b/ipc/BUILD.gn index a63907022b583d..3d020c55f01846 100644 --- a/ipc/BUILD.gn +++ b/ipc/BUILD.gn @@ -22,7 +22,6 @@ buildflag_header("ipc_features") { component("ipc") { sources = [ - "export_template.h", "ipc_channel.cc", "ipc_channel.h", "ipc_channel_common.cc", diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h index ccb7ce4a17a046..2cab6fb258b8be 100644 --- a/ipc/ipc_message_macros.h +++ b/ipc/ipc_message_macros.h @@ -201,7 +201,7 @@ #include -#include "ipc/export_template.h" +#include "base/export_template.h" #include "ipc/ipc_message_templates.h" #include "ipc/ipc_message_utils.h" #include "ipc/param_traits_macros.h" diff --git a/url/BUILD.gn b/url/BUILD.gn index 82eb115ae66633..d33801bc8ae857 100644 --- a/url/BUILD.gn +++ b/url/BUILD.gn @@ -25,6 +25,7 @@ component("url") { "scheme_host_port.h", "third_party/mozilla/url_parse.cc", "third_party/mozilla/url_parse.h", + "url_canon.cc", "url_canon.h", "url_canon_etc.cc", "url_canon_filesystemurl.cc", diff --git a/url/url_canon.cc b/url/url_canon.cc new file mode 100644 index 00000000000000..d51a3179e108e5 --- /dev/null +++ b/url/url_canon.cc @@ -0,0 +1,12 @@ +// Copyright 2017 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 "url/url_canon.h" + +namespace url { + +template class EXPORT_TEMPLATE_DEFINE(URL_EXPORT) CanonOutputT; +template class EXPORT_TEMPLATE_DEFINE(URL_EXPORT) CanonOutputT; + +} // namespace url diff --git a/url/url_canon.h b/url/url_canon.h index 887150b0591791..ede62d327bd762 100644 --- a/url/url_canon.h +++ b/url/url_canon.h @@ -8,6 +8,7 @@ #include #include +#include "base/export_template.h" #include "base/strings/string16.h" #include "url/third_party/mozilla/url_parse.h" #include "url/url_export.h" @@ -174,6 +175,11 @@ class RawCanonOutputT : public CanonOutputT { T fixed_buffer_[fixed_capacity]; }; +// Explicitely instantiate commonly used instatiations. +extern template class EXPORT_TEMPLATE_DECLARE(URL_EXPORT) CanonOutputT; +extern template class EXPORT_TEMPLATE_DECLARE(URL_EXPORT) + CanonOutputT; + // Normally, all canonicalization output is in narrow characters. We support // the templates so it can also be used internally if a wide buffer is // required.