Skip to content

Commit

Permalink
Export CanonOutputT template instantiations to avoid double definition.
Browse files Browse the repository at this point in the history
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 <mlamouri@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#508734}
  • Loading branch information
mounirlamouri authored and Commit Bot committed Oct 13, 2017
1 parent e3057d5 commit 130ad75
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions ipc/export_template.h → base/export_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -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_
1 change: 0 additions & 1 deletion ipc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ buildflag_header("ipc_features") {

component("ipc") {
sources = [
"export_template.h",
"ipc_channel.cc",
"ipc_channel.h",
"ipc_channel_common.cc",
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_message_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

#include <tuple>

#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"
Expand Down
1 change: 1 addition & 0 deletions url/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions url/url_canon.cc
Original file line number Diff line number Diff line change
@@ -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<char>;
template class EXPORT_TEMPLATE_DEFINE(URL_EXPORT) CanonOutputT<base::char16>;

} // namespace url
6 changes: 6 additions & 0 deletions url/url_canon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>

#include "base/export_template.h"
#include "base/strings/string16.h"
#include "url/third_party/mozilla/url_parse.h"
#include "url/url_export.h"
Expand Down Expand Up @@ -174,6 +175,11 @@ class RawCanonOutputT : public CanonOutputT<T> {
T fixed_buffer_[fixed_capacity];
};

// Explicitely instantiate commonly used instatiations.
extern template class EXPORT_TEMPLATE_DECLARE(URL_EXPORT) CanonOutputT<char>;
extern template class EXPORT_TEMPLATE_DECLARE(URL_EXPORT)
CanonOutputT<base::char16>;

// 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.
Expand Down

0 comments on commit 130ad75

Please sign in to comment.