summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authoryzshen <yzshen@chromium.org>2016-02-12 17:10:46 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-13 01:13:27 +0000
commit48f0c963ba40f0b3b7768c9d7f36bd51346ebeb5 (patch)
treee3b4d4f5458bb914cf6798eece128b3608055535 /components
parent07eb2f07100d7439592d80471454b8e2ecb83388 (diff)
downloadchromium_src-48f0c963ba40f0b3b7768c9d7f36bd51346ebeb5.zip
chromium_src-48f0c963ba40f0b3b7768c9d7f36bd51346ebeb5.tar.gz
chromium_src-48f0c963ba40f0b3b7768c9d7f36bd51346ebeb5.tar.bz2
Mojo C++ bindings: make Array/Map/String non-null by default.
Array<X> a; // Default construct an empty array. Array<X> b(nullptr); // Construct a null array. a.clear(); // Set to an empty array. a = nullptr; // Set to a null array. BUG=579634 TEST=None Review URL: https://codereview.chromium.org/1693943002 Cr-Commit-Position: refs/heads/master@{#375304}
Diffstat (limited to 'components')
-rw-r--r--components/filesystem/directory_impl.cc8
-rw-r--r--components/mus/public/cpp/lib/window.cc2
-rw-r--r--components/mus/public/cpp/lib/window_tree_client_impl.cc4
-rw-r--r--components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc2
-rw-r--r--components/mus/ws/window_tree_apptest.cc2
-rw-r--r--components/mus/ws/window_tree_impl.cc2
-rw-r--r--components/mus/ws/window_tree_unittest.cc1
7 files changed, 9 insertions, 12 deletions
diff --git a/components/filesystem/directory_impl.cc b/components/filesystem/directory_impl.cc
index 7fd7a4c..3b4e74d 100644
--- a/components/filesystem/directory_impl.cc
+++ b/components/filesystem/directory_impl.cc
@@ -30,7 +30,7 @@ DirectoryImpl::~DirectoryImpl() {
}
void DirectoryImpl::Read(const ReadCallback& callback) {
- mojo::Array<DirectoryEntryPtr> entries(0);
+ mojo::Array<DirectoryEntryPtr> entries;
base::FileEnumerator directory_enumerator(
directory_path_, false,
base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES);
@@ -221,18 +221,18 @@ void DirectoryImpl::ReadEntireFile(const mojo::String& raw_path,
base::FilePath path;
FileError error = ValidatePath(raw_path, directory_path_, &path);
if (error != FileError::OK) {
- callback.Run(error, mojo::Array<uint8_t>(0));
+ callback.Run(error, mojo::Array<uint8_t>());
return;
}
if (base::DirectoryExists(path)) {
- callback.Run(FileError::NOT_A_FILE, mojo::Array<uint8_t>(0));
+ callback.Run(FileError::NOT_A_FILE, mojo::Array<uint8_t>());
return;
}
base::File base_file(path, base::File::FLAG_OPEN | base::File::FLAG_READ);
if (!base_file.IsValid()) {
- callback.Run(GetError(base_file), mojo::Array<uint8_t>(0));
+ callback.Run(GetError(base_file), mojo::Array<uint8_t>());
return;
}
diff --git a/components/mus/public/cpp/lib/window.cc b/components/mus/public/cpp/lib/window.cc
index 8c2ec50..1f8f3ea 100644
--- a/components/mus/public/cpp/lib/window.cc
+++ b/components/mus/public/cpp/lib/window.cc
@@ -495,7 +495,7 @@ void Window::SetSharedPropertyInternal(const std::string& name,
return;
if (connection_) {
- mojo::Array<uint8_t> transport_value;
+ mojo::Array<uint8_t> transport_value(nullptr);
if (value) {
transport_value.resize(value->size());
if (value->size())
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc
index 0a7426f..2d609fe 100644
--- a/components/mus/public/cpp/lib/window_tree_client_impl.cc
+++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
@@ -299,7 +299,7 @@ void WindowTreeClientImpl::SetProperty(Window* window,
mojo::Array<uint8_t> data) {
DCHECK(tree_);
- mojo::Array<uint8_t> old_value;
+ mojo::Array<uint8_t> old_value(nullptr);
if (window->HasSharedProperty(name))
old_value = mojo::Array<uint8_t>::From(window->properties_[name]);
@@ -435,8 +435,6 @@ Window* WindowTreeClientImpl::NewWindowImpl(
if (properties) {
transport_properties =
mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(*properties);
- } else {
- transport_properties.mark_non_null();
}
if (type == NewWindowType::CHILD) {
tree_->NewWindow(change_id, window->id(), std::move(transport_properties));
diff --git a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
index c1159d5..dc19a84 100644
--- a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
+++ b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc
@@ -62,7 +62,7 @@ class WindowTreeClientImplPrivate {
root_data->parent_id = 0;
root_data->window_id = 1;
root_data->bounds = mojo::Rect::From(gfx::Rect());
- root_data->properties.mark_non_null();
+ root_data->properties.SetToEmpty();
root_data->visible = true;
root_data->drawn = true;
root_data->viewport_metrics = mojom::ViewportMetrics::New();
diff --git a/components/mus/ws/window_tree_apptest.cc b/components/mus/ws/window_tree_apptest.cc
index bc55a76..ee2a186 100644
--- a/components/mus/ws/window_tree_apptest.cc
+++ b/components/mus/ws/window_tree_apptest.cc
@@ -234,7 +234,7 @@ class TestWindowTreeClientImpl : public mojom::WindowTreeClient,
bool SetWindowProperty(Id window_id,
const std::string& name,
const std::vector<uint8_t>* data) {
- Array<uint8_t> mojo_data;
+ Array<uint8_t> mojo_data(nullptr);
if (data)
mojo_data = Array<uint8_t>::From(*data);
const uint32_t change_id = GetAndAdvanceChangeId();
diff --git a/components/mus/ws/window_tree_impl.cc b/components/mus/ws/window_tree_impl.cc
index df73c46..f144d3a 100644
--- a/components/mus/ws/window_tree_impl.cc
+++ b/components/mus/ws/window_tree_impl.cc
@@ -397,7 +397,7 @@ void WindowTreeImpl::ProcessWindowPropertyChanged(
if (!IsWindowKnown(window, &client_window_id))
return;
- Array<uint8_t> data;
+ Array<uint8_t> data(nullptr);
if (new_data)
data = Array<uint8_t>::From(*new_data);
diff --git a/components/mus/ws/window_tree_unittest.cc b/components/mus/ws/window_tree_unittest.cc
index 8eea452..99e53a5 100644
--- a/components/mus/ws/window_tree_unittest.cc
+++ b/components/mus/ws/window_tree_unittest.cc
@@ -849,7 +849,6 @@ TEST_F(WindowTreeTest, NewTopLevelWindow) {
// Create a new top level window.
mojo::Map<mojo::String, mojo::Array<uint8_t>> properties;
- properties.mark_non_null();
const uint32_t initial_change_id = 17;
// Explicitly use an id that does not contain the connection id.
const ClientWindowId embed_window_id2_in_child(45 << 16 | 27);