Commit b642ac3d authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

WTF: Unify std::string specializations of CrossThreadCopier and avoid ODR violations.

It is an ODR violation for conflicting specializations for std::string to exist. Since
this is safe and reasonable, write a single std::basic_string<...> specialization in
cross_thread_copier.h to apply to std::string (and, should it come up in the future,
other specializations of basic_string).

Change-Id: I39b796aaf4c86edc00f46239da008e15110cebc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1743100
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685483}
parent 1cd83a59
......@@ -59,13 +59,6 @@ struct CrossThreadCopier<media::WebmMuxer::VideoParameters> {
static Type Copy(Type pointer) { return pointer; }
};
template <>
struct CrossThreadCopier<std::string> {
STATIC_ONLY(CrossThreadCopier);
using Type = std::string;
static Type Copy(Type&& value) { return std::move(value); }
};
} // namespace WTF
namespace blink {
......
......@@ -39,12 +39,6 @@ struct P2PQuicTransportConfig;
namespace WTF {
template <>
struct CrossThreadCopier<std::string>
: public CrossThreadCopierPassThrough<std::string> {
STATIC_ONLY(CrossThreadCopier);
};
template <>
struct CrossThreadCopier<cricket::IceParameters>
: public CrossThreadCopierPassThrough<cricket::IceParameters> {
......
......@@ -32,6 +32,7 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WTF_CROSS_THREAD_COPIER_H_
#include <memory>
#include <string>
#include <vector>
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
......@@ -175,6 +176,15 @@ struct CrossThreadCopier<std::vector<uint8_t>> {
static Type Copy(Type value) { return value; }
};
template <class CharT, class Traits, class Allocator>
struct CrossThreadCopier<std::basic_string<CharT, Traits, Allocator>> {
STATIC_ONLY(CrossThreadCopier);
using Type = std::basic_string<CharT, Traits, Allocator>;
static Type Copy(Type string) {
return string; // This is in fact a move.
}
};
template <typename T, wtf_size_t inlineCapacity, typename Allocator>
struct CrossThreadCopier<Vector<T, inlineCapacity, Allocator>> {
STATIC_ONLY(CrossThreadCopier);
......
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