summaryrefslogtreecommitdiff
path: root/chromium/mojo/common
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-08-01 12:59:39 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:40:43 +0000
commit28b1110370900897ab652cb420c371fab8857ad4 (patch)
tree41b32127d23b0df4f2add2a27e12dc87bddb260e /chromium/mojo/common
parent399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (diff)
downloadqtwebengine-chromium-28b1110370900897ab652cb420c371fab8857ad4.tar.gz
BASELINE: Update Chromium to 53.0.2785.41
Also adds a few extra files for extensions. Change-Id: Iccdd55d98660903331cf8b7b29188da781830af4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/mojo/common')
-rw-r--r--chromium/mojo/common/BUILD.gn24
-rw-r--r--chromium/mojo/common/OWNERS2
-rw-r--r--chromium/mojo/common/common_custom_types.mojom15
-rw-r--r--chromium/mojo/common/common_custom_types.typemap17
-rw-r--r--chromium/mojo/common/common_custom_types_unittest.cc186
-rw-r--r--chromium/mojo/common/common_type_converters.cc8
-rw-r--r--chromium/mojo/common/common_type_converters.h5
-rw-r--r--chromium/mojo/common/common_type_converters_unittest.cc17
-rw-r--r--chromium/mojo/common/test_common_custom_types.mojom15
-rw-r--r--chromium/mojo/common/url_type_converters.cc19
-rw-r--r--chromium/mojo/common/url_type_converters.h27
11 files changed, 240 insertions, 95 deletions
diff --git a/chromium/mojo/common/BUILD.gn b/chromium/mojo/common/BUILD.gn
index 7ef74fd5e6b..2edfb6d5c83 100644
--- a/chromium/mojo/common/BUILD.gn
+++ b/chromium/mojo/common/BUILD.gn
@@ -9,7 +9,6 @@ group("common") {
public_deps = [
":common_base",
":common_custom_types",
- ":url_type_converters",
]
}
@@ -39,30 +38,9 @@ component("common_base") {
defines = [ "MOJO_COMMON_IMPLEMENTATION" ]
public_deps = [
- "//mojo/public/cpp/system",
- ]
-
- deps = [
- "//base",
- "//base/third_party/dynamic_annotations",
- "//mojo/public/c/system:for_component",
- "//mojo/public/cpp/bindings",
- ]
-}
-
-# GYP version: mojo/mojo_base.gyp:mojo_url_type_converters
-source_set("url_type_converters") {
- sources = [
- "url_type_converters.cc",
- "url_type_converters.h",
- ]
-
- deps = [
- ":common_base",
"//base",
- "//base/third_party/dynamic_annotations",
"//mojo/public/cpp/bindings",
- "//url",
+ "//mojo/public/cpp/system",
]
}
diff --git a/chromium/mojo/common/OWNERS b/chromium/mojo/common/OWNERS
new file mode 100644
index 00000000000..a1660982293
--- /dev/null
+++ b/chromium/mojo/common/OWNERS
@@ -0,0 +1,2 @@
+per-file *_type_converter*.*=set noparent
+per-file *_type_converter*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromium/mojo/common/common_custom_types.mojom b/chromium/mojo/common/common_custom_types.mojom
index 10ebe058be8..aa871064c42 100644
--- a/chromium/mojo/common/common_custom_types.mojom
+++ b/chromium/mojo/common/common_custom_types.mojom
@@ -6,3 +6,18 @@ module mojo.common.mojom;
[Native]
struct FilePath;
+
+[Native]
+struct ListValue;
+
+[Native]
+struct DictionaryValue;
+
+[Native]
+struct Time;
+
+[Native]
+struct TimeDelta;
+
+[Native]
+struct TimeTicks;
diff --git a/chromium/mojo/common/common_custom_types.typemap b/chromium/mojo/common/common_custom_types.typemap
index fc2c767a84f..8d88109d8c1 100644
--- a/chromium/mojo/common/common_custom_types.typemap
+++ b/chromium/mojo/common/common_custom_types.typemap
@@ -3,10 +3,21 @@
# found in the LICENSE file.
mojom = "//mojo/common/common_custom_types.mojom"
-public_headers = [ "//base/files/file_path.h" ]
+public_headers = [
+ "//base/files/file_path.h",
+ "//base/values.h",
+ "//base/time/time.h",
+]
traits_headers = [ "//ipc/ipc_message_utils.h" ]
-deps = [
+public_deps = [
"//ipc",
]
-type_mappings = [ "mojo.common.mojom.FilePath=base::FilePath" ]
+type_mappings = [
+ "mojo.common.mojom.FilePath=base::FilePath",
+ "mojo.common.mojom.DictionaryValue=base::DictionaryValue",
+ "mojo.common.mojom.ListValue=base::ListValue",
+ "mojo.common.mojom.Time=base::Time",
+ "mojo.common.mojom.TimeDelta=base::TimeDelta",
+ "mojo.common.mojom.TimeTicks=base::TimeTicks",
+]
diff --git a/chromium/mojo/common/common_custom_types_unittest.cc b/chromium/mojo/common/common_custom_types_unittest.cc
index 2223c26c2d0..fe6bb5da73a 100644
--- a/chromium/mojo/common/common_custom_types_unittest.cc
+++ b/chromium/mojo/common/common_custom_types_unittest.cc
@@ -5,6 +5,7 @@
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/values.h"
#include "mojo/common/common_custom_types.mojom.h"
#include "mojo/common/test_common_custom_types.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -13,6 +14,44 @@
namespace mojo {
namespace common {
namespace test {
+namespace {
+
+template <typename T>
+struct BounceTestTraits {
+ static void ExpectEquality(const T& a, const T& b) {
+ EXPECT_EQ(a, b);
+ }
+};
+
+template <>
+struct BounceTestTraits<base::DictionaryValue> {
+ static void ExpectEquality(const base::DictionaryValue& a,
+ const base::DictionaryValue& b) {
+ EXPECT_TRUE(a.Equals(&b));
+ }
+};
+
+template <>
+struct BounceTestTraits<base::ListValue> {
+ static void ExpectEquality(const base::ListValue& a,
+ const base::ListValue& b) {
+ EXPECT_TRUE(a.Equals(&b));
+ }
+};
+
+template <typename T>
+void DoExpectResponse(T* expected_value,
+ const base::Closure& closure,
+ const T& value) {
+ BounceTestTraits<T>::ExpectEquality(*expected_value, value);
+ closure.Run();
+}
+
+template <typename T>
+base::Callback<void(const T&)> ExpectResponse(T* expected_value,
+ const base::Closure& closure) {
+ return base::Bind(&DoExpectResponse<T>, expected_value, closure);
+}
class TestFilePathImpl : public TestFilePath {
public:
@@ -29,8 +68,65 @@ class TestFilePathImpl : public TestFilePath {
mojo::Binding<TestFilePath> binding_;
};
-TEST(CommonCustomTypesTest, FilePath) {
- base::MessageLoop message_loop;
+class TestTimeImpl : public TestTime {
+ public:
+ explicit TestTimeImpl(TestTimeRequest request)
+ : binding_(this, std::move(request)) {}
+
+ // TestTime implementation:
+ void BounceTime(const base::Time& in,
+ const BounceTimeCallback& callback) override {
+ callback.Run(in);
+ }
+
+ void BounceTimeDelta(const base::TimeDelta& in,
+ const BounceTimeDeltaCallback& callback) override {
+ callback.Run(in);
+ }
+
+ void BounceTimeTicks(const base::TimeTicks& in,
+ const BounceTimeTicksCallback& callback) override {
+ callback.Run(in);
+ }
+
+ private:
+ mojo::Binding<TestTime> binding_;
+};
+
+class TestValueImpl : public TestValue {
+ public:
+ explicit TestValueImpl(TestValueRequest request)
+ : binding_(this, std::move(request)) {}
+
+ // TestValue implementation:
+ void BounceDictionaryValue(
+ const base::DictionaryValue& in,
+ const BounceDictionaryValueCallback& callback) override {
+ callback.Run(in);
+ }
+ void BounceListValue(const base::ListValue& in,
+ const BounceListValueCallback& callback) override {
+ callback.Run(in);
+ }
+
+ private:
+ mojo::Binding<TestValue> binding_;
+};
+
+class CommonCustomTypesTest : public testing::Test {
+ protected:
+ CommonCustomTypesTest() {}
+ ~CommonCustomTypesTest() override {}
+
+ private:
+ base::MessageLoop message_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(CommonCustomTypesTest);
+};
+
+} // namespace
+
+TEST_F(CommonCustomTypesTest, FilePath) {
base::RunLoop run_loop;
TestFilePathPtr ptr;
@@ -39,14 +135,92 @@ TEST(CommonCustomTypesTest, FilePath) {
base::FilePath dir(FILE_PATH_LITERAL("hello"));
base::FilePath file = dir.Append(FILE_PATH_LITERAL("world"));
- ptr->BounceFilePath(file, [&run_loop, &file](const base::FilePath& out) {
- EXPECT_EQ(file, out);
- run_loop.Quit();
- });
+ ptr->BounceFilePath(file, ExpectResponse(&file, run_loop.QuitClosure()));
+
+ run_loop.Run();
+}
+
+TEST_F(CommonCustomTypesTest, Time) {
+ base::RunLoop run_loop;
+
+ TestTimePtr ptr;
+ TestTimeImpl impl(GetProxy(&ptr));
+
+ base::Time t = base::Time::Now();
+
+ ptr->BounceTime(t, ExpectResponse(&t, run_loop.QuitClosure()));
+
+ run_loop.Run();
+}
+
+TEST_F(CommonCustomTypesTest, TimeDelta) {
+ base::RunLoop run_loop;
+
+ TestTimePtr ptr;
+ TestTimeImpl impl(GetProxy(&ptr));
+
+ base::TimeDelta t = base::TimeDelta::FromDays(123);
+
+ ptr->BounceTimeDelta(t, ExpectResponse(&t, run_loop.QuitClosure()));
run_loop.Run();
}
+TEST_F(CommonCustomTypesTest, TimeTicks) {
+ base::RunLoop run_loop;
+
+ TestTimePtr ptr;
+ TestTimeImpl impl(GetProxy(&ptr));
+
+ base::TimeTicks t = base::TimeTicks::Now();
+
+ ptr->BounceTimeTicks(t, ExpectResponse(&t, run_loop.QuitClosure()));
+
+ run_loop.Run();
+}
+
+TEST_F(CommonCustomTypesTest, Value) {
+ TestValuePtr ptr;
+ TestValueImpl impl(GetProxy(&ptr));
+
+ base::DictionaryValue dict;
+ dict.SetBoolean("bool", false);
+ dict.SetInteger("int", 2);
+ dict.SetString("string", "some string");
+ dict.SetBoolean("nested.bool", true);
+ dict.SetInteger("nested.int", 9);
+ dict.Set("some_binary", base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
+ {
+ std::unique_ptr<base::ListValue> dict_list(new base::ListValue());
+ dict_list->AppendString("string");
+ dict_list->AppendBoolean(true);
+ dict.Set("list", std::move(dict_list));
+ }
+ {
+ base::RunLoop run_loop;
+ ptr->BounceDictionaryValue(
+ dict, ExpectResponse(&dict, run_loop.QuitClosure()));
+ run_loop.Run();
+ }
+
+ base::ListValue list;
+ list.AppendString("string");
+ list.AppendDouble(42.1);
+ list.AppendBoolean(true);
+ list.Append(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
+ {
+ std::unique_ptr<base::DictionaryValue> list_dict(
+ new base::DictionaryValue());
+ list_dict->SetString("string", "str");
+ list.Append(std::move(list_dict));
+ }
+ {
+ base::RunLoop run_loop;
+ ptr->BounceListValue(list, ExpectResponse(&list, run_loop.QuitClosure()));
+ run_loop.Run();
+ }
+}
+
} // namespace test
} // namespace common
} // namespace mojo
diff --git a/chromium/mojo/common/common_type_converters.cc b/chromium/mojo/common/common_type_converters.cc
index 78418f8e41a..92ae3e26820 100644
--- a/chromium/mojo/common/common_type_converters.cc
+++ b/chromium/mojo/common/common_type_converters.cc
@@ -56,6 +56,14 @@ Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
return result;
}
+Array<uint8_t> TypeConverter<Array<uint8_t>, base::StringPiece>::Convert(
+ const base::StringPiece& input) {
+ Array<uint8_t> result(input.size());
+ if (!input.empty())
+ memcpy(&result.front(), input.data(), input.size());
+ return result;
+}
+
base::string16 TypeConverter<base::string16, Array<uint8_t>>::Convert(
const Array<uint8_t>& input) {
if (input.is_null() || input.empty())
diff --git a/chromium/mojo/common/common_type_converters.h b/chromium/mojo/common/common_type_converters.h
index 6dc31f16ad4..a065f050791 100644
--- a/chromium/mojo/common/common_type_converters.h
+++ b/chromium/mojo/common/common_type_converters.h
@@ -47,6 +47,11 @@ struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, std::string> {
};
template <>
+struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, base::StringPiece> {
+ static Array<uint8_t> Convert(const base::StringPiece& input);
+};
+
+template <>
struct MOJO_COMMON_EXPORT TypeConverter<base::string16, Array<uint8_t>> {
static base::string16 Convert(const Array<uint8_t>& input);
};
diff --git a/chromium/mojo/common/common_type_converters_unittest.cc b/chromium/mojo/common/common_type_converters_unittest.cc
index 302bcbe54ab..1740d06a71f 100644
--- a/chromium/mojo/common/common_type_converters_unittest.cc
+++ b/chromium/mojo/common/common_type_converters_unittest.cc
@@ -7,7 +7,6 @@
#include <stdint.h>
#include "base/strings/utf_string_conversions.h"
-#include "mojo/common/url_type_converters.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -71,22 +70,6 @@ TEST(CommonTypeConvertersTest, String16) {
ExpectEqualsMojoString(base::string16(), String::From(base::string16()));
}
-TEST(CommonTypeConvertersTest, URL) {
- GURL url("mojo:foo");
- String mojo_string(String::From(url));
-
- ASSERT_EQ(url.spec(), mojo_string);
- EXPECT_EQ(url.spec(), mojo_string.To<GURL>().spec());
- EXPECT_EQ(url.spec(), String::From(url));
-
- GURL invalid = String().To<GURL>();
- ASSERT_TRUE(invalid.spec().empty());
-
- String string_from_invalid = String::From(invalid);
- EXPECT_FALSE(string_from_invalid.is_null());
- ASSERT_EQ(0U, string_from_invalid.size());
-}
-
TEST(CommonTypeConvertersTest, ArrayUint8ToStdString) {
Array<uint8_t> data(4);
data[0] = 'd';
diff --git a/chromium/mojo/common/test_common_custom_types.mojom b/chromium/mojo/common/test_common_custom_types.mojom
index 0d2f165a809..db91a4f53f4 100644
--- a/chromium/mojo/common/test_common_custom_types.mojom
+++ b/chromium/mojo/common/test_common_custom_types.mojom
@@ -10,3 +10,18 @@ interface TestFilePath {
BounceFilePath(mojo.common.mojom.FilePath in)
=> (mojo.common.mojom.FilePath out);
};
+
+interface TestTime {
+ BounceTime(mojo.common.mojom.Time time) => (mojo.common.mojom.Time time);
+ BounceTimeDelta(mojo.common.mojom.TimeDelta time_delta)
+ => (mojo.common.mojom.TimeDelta time_delta);
+ BounceTimeTicks(mojo.common.mojom.TimeTicks time_ticks)
+ => (mojo.common.mojom.TimeTicks time_ticks);
+};
+
+interface TestValue {
+ BounceDictionaryValue(mojo.common.mojom.DictionaryValue in)
+ => (mojo.common.mojom.DictionaryValue out);
+ BounceListValue(mojo.common.mojom.ListValue in)
+ => (mojo.common.mojom.ListValue out);
+};
diff --git a/chromium/mojo/common/url_type_converters.cc b/chromium/mojo/common/url_type_converters.cc
deleted file mode 100644
index 680252724a9..00000000000
--- a/chromium/mojo/common/url_type_converters.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2015 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 "mojo/common/url_type_converters.h"
-
-#include "url/gurl.h"
-
-namespace mojo {
-
-String TypeConverter<String, GURL>::Convert(const GURL& input) {
- return String(input.spec());
-}
-
-GURL TypeConverter<GURL, String>::Convert(const String& input) {
- return GURL(input.get());
-}
-
-} // namespace mojo
diff --git a/chromium/mojo/common/url_type_converters.h b/chromium/mojo/common/url_type_converters.h
deleted file mode 100644
index 1d334a07fe3..00000000000
--- a/chromium/mojo/common/url_type_converters.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2015 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_COMMON_URL_TYPE_CONVERTERS_H_
-#define MOJO_COMMON_URL_TYPE_CONVERTERS_H_
-
-#include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/bindings/type_converter.h"
-
-class GURL;
-
-namespace mojo {
-
-template <>
-struct TypeConverter<String, GURL> {
- static String Convert(const GURL& input);
-};
-
-template <>
-struct TypeConverter<GURL, String> {
- static GURL Convert(const String& input);
-};
-
-} // namespace mojo
-
-#endif // MOJO_COMMON_URL_TYPE_CONVERTERS_H_