diff --git a/DEPS b/DEPS index 9e6da72..308de8c 100644 --- a/DEPS +++ b/DEPS
@@ -36,7 +36,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '443023975e335e3630191227dbc21fa72c436af3', + 'skia_revision': '48898561db7d50b6d1e0d2048c0a472f9a1d6a28', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other.
diff --git a/chrome/VERSION b/chrome/VERSION index 32f2a84..afdad61 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=54 MINOR=0 -BUILD=2793 +BUILD=2794 PATCH=0
diff --git a/components/filesystem/directory_impl_unittest.cc b/components/filesystem/directory_impl_unittest.cc index 47c3de5..61ced2e 100644 --- a/components/filesystem/directory_impl_unittest.cc +++ b/components/filesystem/directory_impl_unittest.cc
@@ -32,24 +32,23 @@ {"my_file3", mojom::kFlagAppend | mojom::kFlagCreate}}; for (size_t i = 0; i < arraysize(files_to_create); i++) { error = mojom::FileError::FAILED; - directory->OpenFile(files_to_create[i].name, nullptr, - files_to_create[i].open_flags, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->OpenFile(files_to_create[i].name, nullptr, + files_to_create[i].open_flags, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } // Make a directory. error = mojom::FileError::FAILED; - directory->OpenDirectory( + bool handled = directory->OpenDirectory( "my_dir", nullptr, - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); error = mojom::FileError::FAILED; mojo::Array<mojom::DirectoryEntryPtr> directory_contents; - directory->Read(Capture(&error, &directory_contents)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->Read(&error, &directory_contents); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Expected contents of the directory. @@ -80,48 +79,48 @@ // Create my_file. error = mojom::FileError::FAILED; - directory->OpenFile("my_file", nullptr, - mojom::kFlagWrite | mojom::kFlagCreate, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->OpenFile( + "my_file", nullptr, mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Opening my_file should succeed. error = mojom::FileError::FAILED; - directory->OpenFile("my_file", nullptr, mojom::kFlagRead | mojom::kFlagOpen, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->OpenFile("my_file", nullptr, + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Rename my_file to my_new_file. - directory->Rename("my_file", "my_new_file", Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->Rename("my_file", "my_new_file", &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Opening my_file should fail. error = mojom::FileError::FAILED; - directory->OpenFile("my_file", nullptr, mojom::kFlagRead | mojom::kFlagOpen, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->OpenFile("my_file", nullptr, + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_FOUND, error); // Opening my_new_file should succeed. error = mojom::FileError::FAILED; - directory->OpenFile("my_new_file", nullptr, - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->OpenFile("my_new_file", nullptr, + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Delete my_new_file (no flags). - directory->Delete("my_new_file", 0, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->Delete("my_new_file", 0, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Opening my_new_file should fail. error = mojom::FileError::FAILED; - directory->OpenFile("my_new_file", nullptr, - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->OpenFile("my_new_file", nullptr, + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_FOUND, error); } @@ -134,11 +133,10 @@ // Create a directory called 'my_file' mojom::DirectoryPtr my_file_directory; error = mojom::FileError::FAILED; - directory->OpenDirectory( + bool handled = directory->OpenDirectory( "my_file", GetProxy(&my_file_directory), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -146,9 +144,10 @@ // Attempt to open that directory as a file. This must fail! mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_A_FILE, error); } } @@ -171,16 +170,16 @@ std::string data("one two three"); { - clone_one->WriteFile("data", mojo::Array<uint8_t>::From(data), - Capture(&error)); - ASSERT_TRUE(clone_one.WaitForIncomingResponse()); + bool handled = + clone_one->WriteFile("data", mojo::Array<uint8_t>::From(data), &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } { mojo::Array<uint8_t> file_contents; - clone_two->ReadEntireFile("data", Capture(&error, &file_contents)); - ASSERT_TRUE(clone_two.WaitForIncomingResponse()); + bool handled = clone_two->ReadEntireFile("data", &error, &file_contents); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(data, file_contents.To<std::string>()); @@ -194,16 +193,16 @@ std::string data("one two three"); { - directory->WriteFile("data", mojo::Array<uint8_t>::From(data), - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->WriteFile("data", mojo::Array<uint8_t>::From(data), &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } { mojo::Array<uint8_t> file_contents; - directory->ReadEntireFile("data", Capture(&error, &file_contents)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->ReadEntireFile("data", &error, &file_contents); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(data, file_contents.To<std::string>()); @@ -217,8 +216,9 @@ { mojo::Array<uint8_t> file_contents; - directory->ReadEntireFile("doesnt_exist", Capture(&error, &file_contents)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->ReadEntireFile("doesnt_exist", &error, &file_contents); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_FOUND, error); } } @@ -232,19 +232,18 @@ { mojom::DirectoryPtr my_file_directory; error = mojom::FileError::FAILED; - directory->OpenDirectory( + bool handled = directory->OpenDirectory( "my_dir", GetProxy(&my_file_directory), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } // Try to read it as a file { mojo::Array<uint8_t> file_contents; - directory->ReadEntireFile("my_dir", Capture(&error, &file_contents)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->ReadEntireFile("my_dir", &error, &file_contents); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_A_FILE, error); } } @@ -258,19 +257,18 @@ { mojom::DirectoryPtr my_file_directory; error = mojom::FileError::FAILED; - directory->OpenDirectory( + bool handled = directory->OpenDirectory( "my_dir", GetProxy(&my_file_directory), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } { std::string data("one two three"); - directory->WriteFile("my_dir", mojo::Array<uint8_t>::From(data), - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->WriteFile( + "my_dir", mojo::Array<uint8_t>::From(data), &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::NOT_A_FILE, error); } }
diff --git a/components/filesystem/file_impl_unittest.cc b/components/filesystem/file_impl_unittest.cc index 94c8eb4e..443a4a9 100644 --- a/components/filesystem/file_impl_unittest.cc +++ b/components/filesystem/file_impl_unittest.cc
@@ -22,15 +22,16 @@ mojom::DirectoryPtr directory; GetTemporaryRoot(&directory); mojom::FileError error; + bool handled = false; { // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. @@ -42,40 +43,41 @@ bytes_to_write.push_back(static_cast<uint8_t>('o')); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. error = mojom::FileError::FAILED; - file->Close(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Close((&error)); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } // Rename it. error = mojom::FileError::FAILED; - directory->Rename("my_file", "your_file", Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + handled = directory->Rename("my_file", "your_file", &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); { // Open my_file again. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("your_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("your_file", GetProxy(&file), + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Read from it. mojo::Array<uint8_t> bytes_read; error = mojom::FileError::FAILED; - file->Read(3, 1, mojom::Whence::FROM_BEGIN, Capture(&error, &bytes_read)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Read(3, 1, mojom::Whence::FROM_BEGIN, &error, &bytes_read); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_EQ(3u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('e'), bytes_read[0]); @@ -102,26 +104,26 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. error = mojom::FileError::FAILED; - file->Close(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Close((&error)); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -129,26 +131,27 @@ // Open my_file again, this time with read only mode. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Try to write in read mode; it should fail. error = mojom::FileError::OK; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); - ASSERT_TRUE(file.WaitForIncomingResponse()); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::FAILED, error); EXPECT_EQ(0u, num_bytes_written); // Close it. error = mojom::FileError::FAILED; - file->Close(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Close((&error)); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } } @@ -162,10 +165,10 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. @@ -177,17 +180,17 @@ bytes_to_write.push_back(static_cast<uint8_t>('o')); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. error = mojom::FileError::FAILED; - file->Close(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Close(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -195,9 +198,10 @@ // Append to my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagAppend | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagAppend | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. @@ -211,17 +215,17 @@ bytes_to_write.push_back(static_cast<uint8_t>('e')); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. error = mojom::FileError::FAILED; - file->Close(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Close((&error)); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -229,16 +233,17 @@ // Open my_file again. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Read from it. mojo::Array<uint8_t> bytes_read; error = mojom::FileError::FAILED; - file->Read(12, 0, mojom::Whence::FROM_BEGIN, Capture(&error, &bytes_read)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Read(12, 0, mojom::Whence::FROM_BEGIN, &error, &bytes_read); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_EQ(12u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('l'), bytes_read[3]); @@ -257,10 +262,10 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. @@ -272,17 +277,17 @@ bytes_to_write.push_back(static_cast<uint8_t>('o')); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. error = mojom::FileError::FAILED; - file->Close(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Close(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -290,10 +295,10 @@ // Append to my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagOpenTruncated, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->OpenFile( + "my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagOpenTruncated, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. @@ -307,17 +312,17 @@ bytes_to_write.push_back(static_cast<uint8_t>('e')); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); // Close it. error = mojom::FileError::FAILED; - file->Close(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Close(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -325,16 +330,17 @@ // Open my_file again. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Read from it. mojo::Array<uint8_t> bytes_read; error = mojom::FileError::FAILED; - file->Read(7, 0, mojom::Whence::FROM_BEGIN, Capture(&error, &bytes_read)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Read(7, 0, mojom::Whence::FROM_BEGIN, &error, &bytes_read); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_EQ(7u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('g'), bytes_read[0]); @@ -354,16 +360,17 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagCreate, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Stat it. error = mojom::FileError::FAILED; mojom::FileInformationPtr file_info; - file->Stat(Capture(&error, &file_info)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Stat(&error, &file_info); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(mojom::FsFileType::REGULAR_FILE, file_info->type); @@ -378,15 +385,15 @@ t->now = false; const int64_t kPartyTime1 = 1234567890; // Party like it's 2009-02-13. t->seconds = kPartyTime1; - file->Touch(std::move(t), nullptr, Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Touch(std::move(t), nullptr, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Stat again. error = mojom::FileError::FAILED; file_info.reset(); - file->Stat(Capture(&error, &file_info)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Stat(&error, &file_info); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kPartyTime1, file_info->atime); @@ -397,15 +404,15 @@ t->now = false; const int64_t kPartyTime2 = 1425059525; // No time like the present. t->seconds = kPartyTime2; - file->Touch(nullptr, std::move(t), Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Touch(nullptr, std::move(t), &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Stat again. error = mojom::FileError::FAILED; file_info.reset(); - file->Stat(Capture(&error, &file_info)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Stat(&error, &file_info); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kPartyTime1, file_info->atime); @@ -424,18 +431,20 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagCreate, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write(1000, '!'); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); const int size = static_cast<int>(num_bytes_written); @@ -443,8 +452,8 @@ // Tell. error = mojom::FileError::FAILED; int64_t position = -1; - file->Tell(Capture(&error, &position)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Tell(&error, &position); + ASSERT_TRUE(handled); // Should be at the end. EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(size, position); @@ -452,48 +461,48 @@ // Seek back 100. error = mojom::FileError::FAILED; position = -1; - file->Seek(-100, mojom::Whence::FROM_CURRENT, Capture(&error, &position)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Seek(-100, mojom::Whence::FROM_CURRENT, &error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(size - 100, position); // Tell. error = mojom::FileError::FAILED; position = -1; - file->Tell(Capture(&error, &position)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Tell(&error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(size - 100, position); // Seek to 123 from start. error = mojom::FileError::FAILED; position = -1; - file->Seek(123, mojom::Whence::FROM_BEGIN, Capture(&error, &position)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Seek(123, mojom::Whence::FROM_BEGIN, &error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(123, position); // Tell. error = mojom::FileError::FAILED; position = -1; - file->Tell(Capture(&error, &position)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Tell(&error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(123, position); // Seek to 123 back from end. error = mojom::FileError::FAILED; position = -1; - file->Seek(-123, mojom::Whence::FROM_END, Capture(&error, &position)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Seek(-123, mojom::Whence::FROM_END, &error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(size - 123, position); // Tell. error = mojom::FileError::FAILED; position = -1; - file->Tell(Capture(&error, &position)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Tell(&error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(size - 123, position); @@ -509,10 +518,10 @@ // Create my_file. mojom::FilePtr file1; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file1), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->OpenFile( + "my_file", GetProxy(&file1), + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. @@ -524,10 +533,10 @@ bytes_to_write.push_back(static_cast<uint8_t>('o')); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file1->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file1.WaitForIncomingResponse()); + handled = + file1->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(bytes_to_write.size(), num_bytes_written); const int end_hello_pos = static_cast<int>(num_bytes_written); @@ -535,15 +544,15 @@ // Dup it. mojom::FilePtr file2; error = mojom::FileError::FAILED; - file1->Dup(GetProxy(&file2), Capture(&error)); - ASSERT_TRUE(file1.WaitForIncomingResponse()); + handled = file1->Dup(GetProxy(&file2), &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // |file2| should have the same position. error = mojom::FileError::FAILED; int64_t position = -1; - file2->Tell(Capture(&error, &position)); - ASSERT_TRUE(file2.WaitForIncomingResponse()); + handled = file2->Tell(&error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(end_hello_pos, position); @@ -556,10 +565,10 @@ more_bytes_to_write.push_back(static_cast<uint8_t>('d')); error = mojom::FileError::FAILED; num_bytes_written = 0; - file2->Write(mojo::Array<uint8_t>::From(more_bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, - Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file2.WaitForIncomingResponse()); + handled = + file2->Write(mojo::Array<uint8_t>::From(more_bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(more_bytes_to_write.size(), num_bytes_written); const int end_world_pos = end_hello_pos + static_cast<int>(num_bytes_written); @@ -567,22 +576,23 @@ // |file1| should have the same position. error = mojom::FileError::FAILED; position = -1; - file1->Tell(Capture(&error, &position)); - ASSERT_TRUE(file1.WaitForIncomingResponse()); + handled = file1->Tell(&error, &position); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(end_world_pos, position); // Close |file1|. error = mojom::FileError::FAILED; - file1->Close(Capture(&error)); - ASSERT_TRUE(file1.WaitForIncomingResponse()); + handled = file1->Close(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Read everything using |file2|. mojo::Array<uint8_t> bytes_read; error = mojom::FileError::FAILED; - file2->Read(1000, 0, mojom::Whence::FROM_BEGIN, Capture(&error, &bytes_read)); - ASSERT_TRUE(file2.WaitForIncomingResponse()); + handled = + file2->Read(1000, 0, mojom::Whence::FROM_BEGIN, &error, &bytes_read); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_EQ(static_cast<size_t>(end_world_pos), bytes_read.size()); // Just check the first and last bytes. @@ -603,41 +613,43 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagWrite | mojom::kFlagCreate, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file), + mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Write to it. std::vector<uint8_t> bytes_to_write(kInitialSize, '!'); error = mojom::FileError::FAILED; uint32_t num_bytes_written = 0; - file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, - mojom::Whence::FROM_CURRENT, Capture(&error, &num_bytes_written)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = + file->Write(mojo::Array<uint8_t>::From(bytes_to_write), 0, + mojom::Whence::FROM_CURRENT, &error, &num_bytes_written); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); EXPECT_EQ(kInitialSize, num_bytes_written); // Stat it. error = mojom::FileError::FAILED; mojom::FileInformationPtr file_info; - file->Stat(Capture(&error, &file_info)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Stat(&error, &file_info); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kInitialSize, file_info->size); // Truncate it. error = mojom::FileError::FAILED; - file->Truncate(kTruncatedSize, Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Truncate(kTruncatedSize, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Stat again. error = mojom::FileError::FAILED; file_info.reset(); - file->Stat(Capture(&error, &file_info)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Stat(&error, &file_info); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_FALSE(file_info.is_null()); EXPECT_EQ(kTruncatedSize, file_info->size); @@ -652,18 +664,17 @@ // Create my_file. mojom::FilePtr file1; error = mojom::FileError::FAILED; - directory->OpenFile( + bool handled = directory->OpenFile( "my_file", GetProxy(&file1), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Fetch the handle error = mojom::FileError::FAILED; mojo::ScopedHandle handle; - file1->AsHandle(Capture(&error, &handle)); - ASSERT_TRUE(file1.WaitForIncomingResponse()); + handled = file1->AsHandle(&error, &handle); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Pull a file descriptor out of the scoped handle. @@ -682,16 +693,17 @@ // Reopen my_file. mojom::FilePtr file2; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file2), - mojom::kFlagRead | mojom::kFlagOpen, Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = + directory->OpenFile("my_file", GetProxy(&file2), + mojom::kFlagRead | mojom::kFlagOpen, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Verify that we wrote data raw on the file descriptor. mojo::Array<uint8_t> bytes_read; error = mojom::FileError::FAILED; - file2->Read(5, 0, mojom::Whence::FROM_BEGIN, Capture(&error, &bytes_read)); - ASSERT_TRUE(file2.WaitForIncomingResponse()); + handled = file2->Read(5, 0, mojom::Whence::FROM_BEGIN, &error, &bytes_read); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); ASSERT_EQ(5u, bytes_read.size()); EXPECT_EQ(static_cast<uint8_t>('h'), bytes_read[0]); @@ -710,22 +722,22 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->OpenFile( + "my_file", GetProxy(&file), + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Lock the file. error = mojom::FileError::FAILED; - file->Lock(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Lock(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Unlock the file. error = mojom::FileError::FAILED; - file->Unlock(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Unlock(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -737,22 +749,22 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile("my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + bool handled = directory->OpenFile( + "my_file", GetProxy(&file), + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Lock the file. error = mojom::FileError::FAILED; - file->Lock(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Lock(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Lock the file again. error = mojom::FileError::OK; - file->Lock(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Lock(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::FAILED, error); } @@ -765,17 +777,16 @@ // Create my_file. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile( + bool handled = directory->OpenFile( "my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagOpenAlways, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagOpenAlways, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // Lock the file. error = mojom::FileError::FAILED; - file->Lock(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Lock(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } @@ -783,17 +794,16 @@ // Open the file again. mojom::FilePtr file; error = mojom::FileError::FAILED; - directory->OpenFile( + bool handled = directory->OpenFile( "my_file", GetProxy(&file), - mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagOpenAlways, - Capture(&error)); - ASSERT_TRUE(directory.WaitForIncomingResponse()); + mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagOpenAlways, &error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); // The file shouldn't be locked (and we check by trying to lock it). error = mojom::FileError::FAILED; - file->Lock(Capture(&error)); - ASSERT_TRUE(file.WaitForIncomingResponse()); + handled = file->Lock(&error); + ASSERT_TRUE(handled); EXPECT_EQ(mojom::FileError::OK, error); } }
diff --git a/components/filesystem/files_test_base.cc b/components/filesystem/files_test_base.cc index b8a4d08..4312481 100644 --- a/components/filesystem/files_test_base.cc +++ b/components/filesystem/files_test_base.cc
@@ -26,8 +26,8 @@ void FilesTestBase::GetTemporaryRoot(mojom::DirectoryPtr* directory) { mojom::FileError error = mojom::FileError::FAILED; - files()->OpenTempDirectory(GetProxy(directory), Capture(&error)); - ASSERT_TRUE(files().WaitForIncomingResponse()); + bool handled = files()->OpenTempDirectory(GetProxy(directory), &error); + ASSERT_TRUE(handled); ASSERT_EQ(mojom::FileError::OK, error); }
diff --git a/components/filesystem/public/interfaces/directory.mojom b/components/filesystem/public/interfaces/directory.mojom index 98a2b8c6..104a62f5 100644 --- a/components/filesystem/public/interfaces/directory.mojom +++ b/components/filesystem/public/interfaces/directory.mojom
@@ -91,9 +91,11 @@ Clone(Directory& directory); // Reads the contents of an entire file. + [Sync] ReadEntireFile(string path) => (FileError error, array<uint8> data); // Writes |data| to |path|, overwriting the file if it already exists. + [Sync] WriteFile(string path, array<uint8> data) => (FileError error); // TODO(vtl): directory "streaming"?
diff --git a/components/filesystem/public/interfaces/file.mojom b/components/filesystem/public/interfaces/file.mojom index 6ef7067..05bce45c 100644 --- a/components/filesystem/public/interfaces/file.mojom +++ b/components/filesystem/public/interfaces/file.mojom
@@ -16,6 +16,7 @@ // Flushes/closes this file; no operations may be performed on this file after // this. Note that any error code is strictly informational -- the close may // not be retried. + [Sync] Close() => (FileError err); // Reads (at most) |num_bytes_to_read| from the location specified by @@ -24,42 +25,51 @@ // are read. // TODO(vtl): Clarify when (for what values of |offset|/|whence|) this // modifies the file position. Or maybe there should be a flag? + [Sync] Read(uint32 num_bytes_to_read, int64 offset, Whence whence) => (FileError error, array<uint8>? bytes_read); // Writes |bytes_to_write| to the location specified by |offset|/|whence|. // TODO(vtl): Clarify behavior when |num_bytes_written| is less than the size // of |bytes_to_write|. + [Sync] Write(array<uint8> bytes_to_write, int64 offset, Whence whence) => (FileError error, uint32 num_bytes_written); // Gets the current file position. On success, |position| is the current // offset (in bytes) from the beginning of the file). + [Sync] Tell() => (FileError error, int64 position); // Sets the current file position to that specified by |offset|/|whence|. On // success, |position| is the offset (in bytes) from the beginning of the // file. + [Sync] Seek(int64 offset, Whence whence) => (FileError error, int64 position); // Gets information about this file. On success, |file_information| is // non-null and will contain this information. + [Sync] Stat() => (FileError error, FileInformation? file_information); // Truncates this file to the size specified by |size| (in bytes). + [Sync] Truncate(int64 size) => (FileError error); // Updates this file's atime and/or mtime to the time specified by |atime| (or // |mtime|, respectively), which may also indicate "now". If |atime| or // |mtime| is null, then the corresponding time is not modified. + [Sync] Touch(TimespecOrNow? atime, TimespecOrNow? mtime) => (FileError error); // Creates a new |File| instance, which shares the same "file description". // I.e., the access mode, etc. (as specified to |Directory::OpenFile()| by the // |open_flags| argument) as well as file position. + [Sync] Dup(File& file) => (FileError error); // Syncs data to disk. + [Sync] Flush() => (FileError error); // Attempts to take an exclusive write lock on the file. This both takes a @@ -73,5 +83,6 @@ Unlock() => (FileError error); // Returns a handle to the file for raw access. + [Sync] AsHandle() => (FileError error, handle file_handle); };
diff --git a/components/filesystem/public/interfaces/file_system.mojom b/components/filesystem/public/interfaces/file_system.mojom index 52b98684..a2ab7961 100644 --- a/components/filesystem/public/interfaces/file_system.mojom +++ b/components/filesystem/public/interfaces/file_system.mojom
@@ -10,8 +10,10 @@ interface FileSystem { // Opens a temporary filesystem. Will return a different directory each time // it is called. + [Sync] OpenTempDirectory(Directory& directory) => (FileError error); // Returns a directory which will persist to disk. + [Sync] OpenPersistentFileSystem(Directory& directory) => (FileError error); };
diff --git a/components/leveldb/leveldb_service_unittest.cc b/components/leveldb/leveldb_service_unittest.cc index f6160c0..598f488 100644 --- a/components/leveldb/leveldb_service_unittest.cc +++ b/components/leveldb/leveldb_service_unittest.cc
@@ -4,6 +4,7 @@ #include "base/bind.h" #include "base/macros.h" +#include "base/run_loop.h" #include "components/filesystem/public/interfaces/directory.mojom.h" #include "components/filesystem/public/interfaces/file_system.mojom.h" #include "components/filesystem/public/interfaces/types.mojom.h" @@ -21,18 +22,72 @@ template <typename... Args> void IgnoreAllArgs(Args&&...) {} template <typename... Args> -void DoCaptures(Args*... out_args, Args... in_args) { +void DoCaptures(Args*... out_args, + const base::Closure& quit_closure, + Args... in_args) { IgnoreAllArgs((*out_args = std::move(in_args))...); + quit_closure.Run(); } template <typename T1> -base::Callback<void(T1)> Capture(T1* t1) { - return base::Bind(&DoCaptures<T1>, t1); +base::Callback<void(T1)> Capture(T1* t1, const base::Closure& quit_closure) { + return base::Bind(&DoCaptures<T1>, t1, quit_closure); } template <typename T1, typename T2> -base::Callback<void(T1, T2)> Capture(T1* t1, T2* t2) { - return base::Bind(&DoCaptures<T1, T2>, t1, t2); +base::Callback<void(T1, T2)> Capture(T1* t1, + T2* t2, + const base::Closure& quit_closure) { + return base::Bind(&DoCaptures<T1, T2>, t1, t2, quit_closure); +} + +void DatabaseSyncPut(mojom::LevelDBDatabase* database, + mojo::Array<uint8_t> key, + mojo::Array<uint8_t> value, + mojom::DatabaseError* out_error) { + base::RunLoop run_loop; + database->Put(std::move(key), std::move(value), + Capture(out_error, run_loop.QuitClosure())); + run_loop.Run(); +} + +void DatabaseSyncGet(mojom::LevelDBDatabase* database, + mojo::Array<uint8_t> key, + mojom::DatabaseError* out_error, + mojo::Array<uint8_t>* out_value) { + base::RunLoop run_loop; + database->Get(std::move(key), + Capture(out_error, out_value, run_loop.QuitClosure())); + run_loop.Run(); +} + +void DatabaseSyncGetPrefixed(mojom::LevelDBDatabase* database, + mojo::Array<uint8_t> key_prefix, + mojom::DatabaseError* out_error, + mojo::Array<mojom::KeyValuePtr>* out_key_values) { + base::RunLoop run_loop; + database->GetPrefixed( + std::move(key_prefix), + Capture(out_error, out_key_values, run_loop.QuitClosure())); + run_loop.Run(); +} + +void DatabaseSyncDeletePrefixed(mojom::LevelDBDatabase* database, + mojo::Array<uint8_t> key_prefix, + mojom::DatabaseError* out_error) { + base::RunLoop run_loop; + database->DeletePrefixed(std::move(key_prefix), + Capture(out_error, run_loop.QuitClosure())); + run_loop.Run(); +} + +void LevelDBSyncOpenInMemory(mojom::LevelDBService* leveldb, + mojom::LevelDBDatabaseRequest database, + mojom::DatabaseError* out_error) { + base::RunLoop run_loop; + leveldb->OpenInMemory(std::move(database), + Capture(out_error, run_loop.QuitClosure())); + run_loop.Run(); } class LevelDBServiceTest : public shell::test::ServiceTest { @@ -58,8 +113,8 @@ // since |ASSERT_...()| doesn't work with return values. void GetTempDirectory(filesystem::mojom::DirectoryPtr* directory) { FileError error = FileError::FAILED; - files()->OpenTempDirectory(GetProxy(directory), Capture(&error)); - ASSERT_TRUE(files().WaitForIncomingResponse()); + bool handled = files()->OpenTempDirectory(GetProxy(directory), &error); + ASSERT_TRUE(handled); ASSERT_EQ(FileError::OK, error); } @@ -76,40 +131,39 @@ TEST_F(LevelDBServiceTest, Basic) { mojom::DatabaseError error; mojom::LevelDBDatabasePtr database; - leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + LevelDBSyncOpenInMemory(leveldb().get(), GetProxy(&database), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Write a key to the database. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(std::string("key")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Read the key back from the database. error = mojom::DatabaseError::INVALID_ARGUMENT; mojo::Array<uint8_t> value; - database->Get(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("value", value.To<std::string>()); // Delete the key from the database. error = mojom::DatabaseError::INVALID_ARGUMENT; + base::RunLoop run_loop; database->Delete(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + Capture(&error, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); // Read the key back from the database. error = mojom::DatabaseError::INVALID_ARGUMENT; value.SetToEmpty(); - database->Get(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::NOT_FOUND, error); EXPECT_EQ("", value.To<std::string>()); } @@ -117,15 +171,13 @@ TEST_F(LevelDBServiceTest, WriteBatch) { mojom::DatabaseError error; mojom::LevelDBDatabasePtr database; - leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + LevelDBSyncOpenInMemory(leveldb().get(), GetProxy(&database), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Write a key to the database. - database->Put(mojo::Array<uint8_t>::From(std::string("key")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Create a batched operation which both deletes "key" and adds another write. @@ -141,37 +193,37 @@ item->value = mojo::Array<uint8_t>::From(std::string("more")); operations.push_back(std::move(item)); - database->Write(std::move(operations), Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + base::RunLoop run_loop; + database->Write(std::move(operations), + Capture(&error, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); // Reading "key" should be invalid now. error = mojom::DatabaseError::INVALID_ARGUMENT; mojo::Array<uint8_t> value; - database->Get(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::NOT_FOUND, error); EXPECT_EQ("", value.To<std::string>()); // Reading "other" should return "more" error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Get(mojo::Array<uint8_t>::From(std::string("other")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("other")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("more", value.To<std::string>()); // Write a some prefixed keys to the database. - database->Put(mojo::Array<uint8_t>::From(std::string("prefix-key1")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("prefix-key1")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); - database->Put(mojo::Array<uint8_t>::From(std::string("prefix-key2")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("prefix-key2")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Create a batched operation to delete them. @@ -180,24 +232,26 @@ item->type = mojom::BatchOperationType::DELETE_PREFIXED_KEY; item->key = mojo::Array<uint8_t>::From(std::string("prefix")); operations.push_back(std::move(item)); - database->Write(std::move(operations), Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + base::RunLoop run_loop2; + database->Write(std::move(operations), + Capture(&error, run_loop2.QuitClosure())); + run_loop2.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); // Reading all "prefix" keys should be invalid now. error = mojom::DatabaseError::INVALID_ARGUMENT; value = nullptr; - database->Get(mojo::Array<uint8_t>::From(std::string("prefix-key1")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("prefix-key1")), + &error, &value); EXPECT_EQ(mojom::DatabaseError::NOT_FOUND, error); EXPECT_EQ("", value.To<std::string>()); // Reading "key" should be invalid now. error = mojom::DatabaseError::INVALID_ARGUMENT; value = nullptr; - database->Get(mojo::Array<uint8_t>::From(std::string("prefix-key2")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("prefix-key2")), + &error, &value); EXPECT_EQ(mojom::DatabaseError::NOT_FOUND, error); EXPECT_EQ("", value.To<std::string>()); } @@ -216,19 +270,18 @@ leveldb::mojom::OpenOptionsPtr options = leveldb::mojom::OpenOptions::New(); options->error_if_exists = true; options->create_if_missing = true; - leveldb()->OpenWithOptions(std::move(options), - std::move(directory), "test", + base::RunLoop run_loop; + leveldb()->OpenWithOptions(std::move(options), std::move(directory), "test", GetProxy(&database), - Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + Capture(&error, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); // Write a key to the database. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(std::string("key")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // The database should go out of scope here. @@ -240,17 +293,18 @@ // Reconnect to the database. mojom::LevelDBDatabasePtr database; + base::RunLoop run_loop; leveldb()->Open(std::move(directory), "test", GetProxy(&database), - Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + Capture(&error, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); // We should still be able to read the key back from the database. error = mojom::DatabaseError::INVALID_ARGUMENT; mojo::Array<uint8_t> value; - database->Get(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("value", value.To<std::string>()); } @@ -259,61 +313,59 @@ TEST_F(LevelDBServiceTest, GetSnapshotSimple) { mojom::DatabaseError error; mojom::LevelDBDatabasePtr database; - leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + LevelDBSyncOpenInMemory(leveldb().get(), GetProxy(&database), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); uint64_t snapshot_id = 0; - database->GetSnapshot(Capture(&snapshot_id)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + base::RunLoop run_loop; + database->GetSnapshot(Capture(&snapshot_id, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_NE(static_cast<uint64_t>(0), snapshot_id); } TEST_F(LevelDBServiceTest, GetFromSnapshots) { mojom::DatabaseError error; mojom::LevelDBDatabasePtr database; - leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + LevelDBSyncOpenInMemory(leveldb().get(), GetProxy(&database), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Write a key to the database. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(std::string("key")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Take a snapshot where key=value. uint64_t key_value_snapshot = 0; - database->GetSnapshot(Capture(&key_value_snapshot)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + base::RunLoop run_loop; + database->GetSnapshot(Capture(&key_value_snapshot, run_loop.QuitClosure())); + run_loop.Run(); // Change key to "yek". error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(std::string("key")), - mojo::Array<uint8_t>::From(std::string("yek")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), + mojo::Array<uint8_t>::From(std::string("yek")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // (Ensure this change is live on the database.) error = mojom::DatabaseError::INVALID_ARGUMENT; mojo::Array<uint8_t> value; - database->Get(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("yek", value.To<std::string>()); // But if we were to read from the snapshot, we'd still get value. error = mojom::DatabaseError::INVALID_ARGUMENT; value.SetToEmpty(); - database->GetFromSnapshot( - key_value_snapshot, - mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + base::RunLoop run_loop2; + database->GetFromSnapshot(key_value_snapshot, + mojo::Array<uint8_t>::From(std::string("key")), + Capture(&error, &value, run_loop2.QuitClosure())); + run_loop2.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("value", value.To<std::string>()); } @@ -321,59 +373,57 @@ TEST_F(LevelDBServiceTest, InvalidArgumentOnInvalidSnapshot) { mojom::LevelDBDatabasePtr database; mojom::DatabaseError error = mojom::DatabaseError::INVALID_ARGUMENT; - leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + LevelDBSyncOpenInMemory(leveldb().get(), GetProxy(&database), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); uint64_t invalid_snapshot = 8; error = mojom::DatabaseError::OK; mojo::Array<uint8_t> value; - database->GetFromSnapshot( - invalid_snapshot, - mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + base::RunLoop run_loop; + database->GetFromSnapshot(invalid_snapshot, + mojo::Array<uint8_t>::From(std::string("key")), + Capture(&error, &value, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::INVALID_ARGUMENT, error); } TEST_F(LevelDBServiceTest, MemoryDBReadWrite) { mojom::LevelDBDatabasePtr database; mojom::DatabaseError error = mojom::DatabaseError::INVALID_ARGUMENT; - leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + LevelDBSyncOpenInMemory(leveldb().get(), GetProxy(&database), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Write a key to the database. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(std::string("key")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); // Read the key back from the database. error = mojom::DatabaseError::INVALID_ARGUMENT; mojo::Array<uint8_t> value; - database->Get(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("value", value.To<std::string>()); // Delete the key from the database. error = mojom::DatabaseError::INVALID_ARGUMENT; + base::RunLoop run_loop; database->Delete(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + Capture(&error, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); // Read the key back from the database. error = mojom::DatabaseError::INVALID_ARGUMENT; value.SetToEmpty(); - database->Get(mojo::Array<uint8_t>::From(std::string("key")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("key")), &error, + &value); EXPECT_EQ(mojom::DatabaseError::NOT_FOUND, error); EXPECT_EQ("", value.To<std::string>()); } @@ -382,8 +432,7 @@ // Open an in memory database for speed. mojom::DatabaseError error = mojom::DatabaseError::INVALID_ARGUMENT; mojom::LevelDBDatabasePtr database; - leveldb()->OpenInMemory(GetProxy(&database), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + LevelDBSyncOpenInMemory(leveldb().get(), GetProxy(&database), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); const std::string prefix("prefix"); @@ -391,60 +440,50 @@ // Completely empty database. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error, &key_values)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGetPrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error, &key_values); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_TRUE(key_values.empty()); // No values with our prefix, but values before and after. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(std::string("a-before-prefix")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("a-before-prefix")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(std::string("z-after-prefix")), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), + mojo::Array<uint8_t>::From(std::string("z-after-prefix")), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); key_values.SetToEmpty(); error = mojom::DatabaseError::INVALID_ARGUMENT; - database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error, &key_values)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGetPrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error, &key_values); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_TRUE(key_values.empty()); // One value with the exact prefix. - database->Put(mojo::Array<uint8_t>::From(prefix), - mojo::Array<uint8_t>::From(std::string("value")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), mojo::Array<uint8_t>::From(prefix), + mojo::Array<uint8_t>::From(std::string("value")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); error = mojom::DatabaseError::INVALID_ARGUMENT; key_values.SetToEmpty(); - database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error, &key_values)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGetPrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error, &key_values); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ(1u, key_values.size()); EXPECT_EQ("prefix", key_values[0]->key.To<std::string>()); EXPECT_EQ("value", key_values[0]->value.To<std::string>()); // Multiple values with starting with the prefix. - database->Put(mojo::Array<uint8_t>::From(prefix + "2"), - mojo::Array<uint8_t>::From(std::string("value2")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), mojo::Array<uint8_t>::From(prefix + "2"), + mojo::Array<uint8_t>::From(std::string("value2")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); error = mojom::DatabaseError::INVALID_ARGUMENT; key_values.SetToEmpty(); - database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error, &key_values)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGetPrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error, &key_values); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ(2u, key_values.size()); EXPECT_EQ("prefix", key_values[0]->key.To<std::string>()); @@ -454,29 +493,27 @@ // Delete the prefixed values. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->DeletePrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncDeletePrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error); EXPECT_EQ(mojom::DatabaseError::OK, error); error = mojom::DatabaseError::INVALID_ARGUMENT; key_values.SetToEmpty(); - database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error, &key_values)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGetPrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error, &key_values); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_TRUE(key_values.empty()); // Make sure the others are not deleted. mojo::Array<uint8_t> value; - database->Get(mojo::Array<uint8_t>::From(std::string("a-before-prefix")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("a-before-prefix")), + &error, &value); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("value", value.To<std::string>()); value.SetToEmpty(); - database->Get(mojo::Array<uint8_t>::From(std::string("z-after-prefix")), - Capture(&error, &value)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGet(database.get(), + mojo::Array<uint8_t>::From(std::string("z-after-prefix")), + &error, &value); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ("value", value.To<std::string>()); @@ -484,30 +521,25 @@ // Even thought there is no exact matching key, GetPrefixed // and DeletePrefixed still operate on the values. error = mojom::DatabaseError::INVALID_ARGUMENT; - database->Put(mojo::Array<uint8_t>::From(prefix + "2"), - mojo::Array<uint8_t>::From(std::string("value2")), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncPut(database.get(), mojo::Array<uint8_t>::From(prefix + "2"), + mojo::Array<uint8_t>::From(std::string("value2")), &error); EXPECT_EQ(mojom::DatabaseError::OK, error); error = mojom::DatabaseError::INVALID_ARGUMENT; key_values.SetToEmpty(); - database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error, &key_values)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGetPrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error, &key_values); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_EQ(1u, key_values.size()); EXPECT_EQ("prefix2", key_values[0]->key.To<std::string>()); EXPECT_EQ("value2", key_values[0]->value.To<std::string>()); error = mojom::DatabaseError::INVALID_ARGUMENT; - database->DeletePrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncDeletePrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error); EXPECT_EQ(mojom::DatabaseError::OK, error); error = mojom::DatabaseError::INVALID_ARGUMENT; key_values.SetToEmpty(); - database->GetPrefixed(mojo::Array<uint8_t>::From(prefix), - Capture(&error, &key_values)); - ASSERT_TRUE(database.WaitForIncomingResponse()); + DatabaseSyncGetPrefixed(database.get(), mojo::Array<uint8_t>::From(prefix), + &error, &key_values); EXPECT_EQ(mojom::DatabaseError::OK, error); EXPECT_TRUE(key_values.empty()); }
diff --git a/components/leveldb/remote_iterator_unittest.cc b/components/leveldb/remote_iterator_unittest.cc index 884915b..4319dc39 100644 --- a/components/leveldb/remote_iterator_unittest.cc +++ b/components/leveldb/remote_iterator_unittest.cc
@@ -4,7 +4,9 @@ #include <map> +#include "base/bind.h" #include "base/macros.h" +#include "base/run_loop.h" #include "components/leveldb/public/cpp/remote_iterator.h" #include "components/leveldb/public/interfaces/leveldb.mojom.h" #include "mojo/common/common_type_converters.h" @@ -15,11 +17,17 @@ namespace { template <typename T> -void DoCapture(T* t, T got_t) { *t = std::move(got_t); } +void DoCapture(T* t, const base::Closure& quit_closure, T got_t) { + *t = std::move(got_t); + if (!quit_closure.is_null()) + quit_closure.Run(); +} template <typename T1> -base::Callback<void(T1)> Capture(T1* t1) { - return base::Bind(&DoCapture<T1>, t1); +base::Callback<void(T1)> Capture( + T1* t1, + const base::Closure& quit_closure = base::Closure()) { + return base::Bind(&DoCapture<T1>, t1, quit_closure); } class RemoteIteratorTest : public shell::test::ServiceTest { @@ -34,8 +42,10 @@ connector()->ConnectToInterface("mojo:leveldb", &leveldb_); mojom::DatabaseError error; - leveldb()->OpenInMemory(GetProxy(&database_), Capture(&error)); - ASSERT_TRUE(leveldb().WaitForIncomingResponse()); + base::RunLoop run_loop; + leveldb()->OpenInMemory(GetProxy(&database_), + Capture(&error, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); std::map<std::string, std::string> data{ @@ -44,9 +54,11 @@ for (auto p : data) { // Write a key to the database. error = mojom::DatabaseError::INVALID_ARGUMENT; + base::RunLoop run_loop; database_->Put(mojo::Array<uint8_t>::From(p.first), - mojo::Array<uint8_t>::From(p.second), Capture(&error)); - ASSERT_TRUE(database_.WaitForIncomingResponse()); + mojo::Array<uint8_t>::From(p.second), + Capture(&error, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_EQ(mojom::DatabaseError::OK, error); } } @@ -68,8 +80,9 @@ TEST_F(RemoteIteratorTest, Seeking) { uint64_t iterator_id = 0; - database()->NewIterator(Capture(&iterator_id)); - ASSERT_TRUE(database().WaitForIncomingResponse()); + base::RunLoop run_loop; + database()->NewIterator(Capture(&iterator_id, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_NE(0u, iterator_id); RemoteIterator it(database().get(), iterator_id); @@ -93,8 +106,9 @@ TEST_F(RemoteIteratorTest, Next) { uint64_t iterator_id = 0; - database()->NewIterator(Capture(&iterator_id)); - ASSERT_TRUE(database().WaitForIncomingResponse()); + base::RunLoop run_loop; + database()->NewIterator(Capture(&iterator_id, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_NE(0u, iterator_id); RemoteIterator it(database().get(), iterator_id); @@ -121,8 +135,9 @@ TEST_F(RemoteIteratorTest, Prev) { uint64_t iterator_id = 0; - database()->NewIterator(Capture(&iterator_id)); - ASSERT_TRUE(database().WaitForIncomingResponse()); + base::RunLoop run_loop; + database()->NewIterator(Capture(&iterator_id, run_loop.QuitClosure())); + run_loop.Run(); EXPECT_NE(0u, iterator_id); RemoteIterator it(database().get(), iterator_id);
diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.cc b/content/renderer/pepper/ppb_graphics_3d_impl.cc index 816c3a3f..8545095e 100644 --- a/content/renderer/pepper/ppb_graphics_3d_impl.cc +++ b/content/renderer/pepper/ppb_graphics_3d_impl.cc
@@ -168,8 +168,7 @@ } int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) { + const gfx::Size& size) { DCHECK(command_buffer_); if (taken_front_buffer_.IsZero()) { DLOG(ERROR) << "TakeFrontBuffer should be called before DoSwapBuffers"; @@ -184,16 +183,11 @@ // // Don't need to check for NULL from GetPluginInstance since when we're // bound, we know our instance is valid. - if (width < 0 || height < 0) { - width = original_width_; - height = original_height_; - } bool is_overlay_candidate = use_image_chromium_; GLenum target = is_overlay_candidate ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D; cc::TextureMailbox texture_mailbox(taken_front_buffer_, sync_token, target, - gfx::Size(width, height), - is_overlay_candidate, false); + size, is_overlay_candidate, false); taken_front_buffer_.SetZero(); HostGlobals::Get() ->GetInstance(pp_instance()) @@ -261,8 +255,6 @@ std::move(channel), gpu::kNullSurfaceHandle, share_buffer, gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, attrib_helper, GURL::EmptyGURL(), base::ThreadTaskRunnerHandle::Get()); - original_width_ = attrib_helper.offscreen_framebuffer_size.width(); - original_height_ = attrib_helper.offscreen_framebuffer_size.height(); if (!command_buffer_) return false;
diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.h b/content/renderer/pepper/ppb_graphics_3d_impl.h index 9255e02..dca5aaa 100644 --- a/content/renderer/pepper/ppb_graphics_3d_impl.h +++ b/content/renderer/pepper/ppb_graphics_3d_impl.h
@@ -75,8 +75,7 @@ gpu::CommandBuffer* GetCommandBuffer() override; gpu::GpuControl* GetGpuControl() override; int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) override; + const gfx::Size& size) override; private: explicit PPB_Graphics3D_Impl(PP_Instance instance); @@ -116,12 +115,6 @@ bool lost_context_ = false; #endif - // The width and height of the command buffer back buffer are first sized from - // this process, but then resized by the pepper process. Cache the original - // size. - int32_t original_width_ = 0; - int32_t original_height_ = 0; - bool has_alpha_; bool use_image_chromium_; std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_;
diff --git a/mash/catalog_viewer/catalog_viewer.cc b/mash/catalog_viewer/catalog_viewer.cc index c621b8c1..a832beb 100644 --- a/mash/catalog_viewer/catalog_viewer.cc +++ b/mash/catalog_viewer/catalog_viewer.cc
@@ -39,8 +39,7 @@ catalog_(std::move(catalog)), table_view_(nullptr), table_view_parent_(nullptr), - observer_(nullptr), - weak_ptr_factory_(this) { + observer_(nullptr) { table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY, false); set_background(views::Background::CreateStandardPanelBackground()); @@ -48,12 +47,15 @@ table_view_parent_ = table_view_->CreateParentIfNecessary(); AddChildView(table_view_parent_); - catalog_->GetEntries(nullptr, - base::Bind(&CatalogViewerContents::OnGotCatalogEntries, - weak_ptr_factory_.GetWeakPtr())); // We don't want to show an empty UI so we just block until we have all the - // data. - catalog_.WaitForIncomingResponse(); + // data. GetEntries is a sync call. + mojo::Array<catalog::mojom::EntryPtr> entries; + bool got = catalog_->GetEntries(nullptr, &entries); + if (got) { + for (auto& entry : entries) + entries_.push_back(Entry(entry->display_name, entry->name)); + observer_->OnModelChanged(); + } } ~CatalogViewerContents() override { table_view_->SetModel(nullptr); @@ -115,13 +117,6 @@ observer_ = observer; } - void OnGotCatalogEntries(mojo::Array<catalog::mojom::EntryPtr> entries) { - entries_.clear(); - for (auto& entry : entries) - entries_.push_back(Entry(entry->display_name, entry->name)); - observer_->OnModelChanged(); - } - static std::vector<ui::TableColumn> GetColumns() { std::vector<ui::TableColumn> columns; @@ -155,8 +150,6 @@ std::vector<Entry> entries_; - base::WeakPtrFactory<CatalogViewerContents> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(CatalogViewerContents); };
diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h index d894984..edcb9bf2 100644 --- a/mojo/public/cpp/bindings/interface_ptr.h +++ b/mojo/public/cpp/bindings/interface_ptr.h
@@ -126,17 +126,6 @@ return internal_state_.HasAssociatedInterfaces(); } - // Blocks the current thread until the next incoming response callback arrives - // or an error occurs. Returns |true| if a response arrived, or |false| in - // case of error. - // - // This method may only be called if the InterfacePtr has been bound to a - // message pipe and there are no associated interfaces running. - bool WaitForIncomingResponse() { - CHECK(!HasAssociatedInterfaces()); - return internal_state_.WaitForIncomingResponse(); - } - // Indicates whether the message pipe has encountered an error. If true, // method calls made on this interface will be dropped (and may already have // been dropped).
diff --git a/mojo/public/cpp/bindings/lib/interface_ptr_state.h b/mojo/public/cpp/bindings/lib/interface_ptr_state.h index c76fc9c..584933eb 100644 --- a/mojo/public/cpp/bindings/lib/interface_ptr_state.h +++ b/mojo/public/cpp/bindings/lib/interface_ptr_state.h
@@ -108,13 +108,6 @@ bool HasAssociatedInterfaces() const { return false; } - bool WaitForIncomingResponse() { - ConfigureProxyIfNecessary(); - - DCHECK(router_); - return router_->WaitForIncomingMessage(MOJO_DEADLINE_INDEFINITE); - } - // After this method is called, the object is in an invalid state and // shouldn't be reused. InterfacePtrInfo<Interface> PassInterface() { @@ -265,13 +258,6 @@ return router_ ? router_->HasAssociatedEndpoints() : false; } - bool WaitForIncomingResponse() { - ConfigureProxyIfNecessary(); - - DCHECK(router_); - return router_->WaitForIncomingMessage(MOJO_DEADLINE_INDEFINITE); - } - // After this method is called, the object is in an invalid state and // shouldn't be reused. InterfacePtrInfo<Interface> PassInterface() {
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc index 4d3a93e..aff62511 100644 --- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc +++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
@@ -59,10 +59,6 @@ : calculator_(std::move(calculator)), output_(0.0) {} - bool WaitForIncomingResponse() { - return calculator_.WaitForIncomingResponse(); - } - bool encountered_error() const { return calculator_.encountered_error(); } void set_connection_error_handler(const base::Closure& closure) { calculator_.set_connection_error_handler(closure); @@ -251,16 +247,18 @@ EXPECT_EQ(0.0, calculator_ui.GetOutput()); - calculator_ui.Add(2.0, base::Closure()); + base::RunLoop run_loop; + calculator_ui.Add(2.0, run_loop.QuitClosure()); EXPECT_EQ(0.0, calculator_ui.GetOutput()); calc_impl.WaitForIncomingMethodCall(); - calculator_ui.WaitForIncomingResponse(); + run_loop.Run(); EXPECT_EQ(2.0, calculator_ui.GetOutput()); - calculator_ui.Multiply(5.0, base::Closure()); + base::RunLoop run_loop2; + calculator_ui.Multiply(5.0, run_loop2.QuitClosure()); EXPECT_EQ(2.0, calculator_ui.GetOutput()); calc_impl.WaitForIncomingMethodCall(); - calculator_ui.WaitForIncomingResponse(); + run_loop2.Run(); EXPECT_EQ(10.0, calculator_ui.GetOutput()); }
diff --git a/net/proxy/proxy_resolver_factory_mojo_unittest.cc b/net/proxy/proxy_resolver_factory_mojo_unittest.cc index da9ac33..75b2d22 100644 --- a/net/proxy/proxy_resolver_factory_mojo_unittest.cc +++ b/net/proxy/proxy_resolver_factory_mojo_unittest.cc
@@ -14,6 +14,7 @@ #include "base/bind.h" #include "base/memory/ptr_util.h" +#include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "base/values.h" @@ -272,7 +273,12 @@ break; } case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT: { - ASSERT_FALSE(client.WaitForIncomingResponse()); + base::MessageLoop::ScopedNestableTaskAllower nestable_allower( + base::MessageLoop::current()); + base::RunLoop run_loop; + client.set_connection_error_handler(run_loop.QuitClosure()); + run_loop.Run(); + ASSERT_TRUE(client.encountered_error()); break; } case GetProxyForUrlAction::MAKE_DNS_REQUEST: { @@ -435,7 +441,12 @@ break; } case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: { - ASSERT_FALSE(client.WaitForIncomingResponse()); + base::MessageLoop::ScopedNestableTaskAllower nestable_allower( + base::MessageLoop::current()); + base::RunLoop run_loop; + client.set_connection_error_handler(run_loop.QuitClosure()); + run_loop.Run(); + ASSERT_TRUE(client.encountered_error()); break; } case CreateProxyResolverAction::MAKE_DNS_REQUEST: {
diff --git a/ppapi/ppapi_internal.gyp b/ppapi/ppapi_internal.gyp index 99b4652d..3f8d0d9 100644 --- a/ppapi/ppapi_internal.gyp +++ b/ppapi/ppapi_internal.gyp
@@ -53,6 +53,7 @@ '../media/media.gyp:shared_memory_support', '../skia/skia.gyp:skia', '../third_party/icu/icu.gyp:icuuc', + '../ui/gfx/gfx.gyp:gfx_geometry', '../ui/surface/surface.gyp:surface', '../url/url.gyp:url_lib', 'ppapi.gyp:ppapi_c', @@ -87,6 +88,7 @@ '../gpu/gpu.gyp:command_buffer_traits', '../ipc/ipc.gyp:ipc', '../skia/skia.gyp:skia', + '../ui/gfx/ipc/geometry/gfx_ipc_geometry.gyp:gfx_ipc_geometry', 'ppapi.gyp:ppapi_c', 'ppapi_shared', ], @@ -168,6 +170,7 @@ '../third_party/icu/icu.gyp:icuuc', '../third_party/icu/icu.gyp:icui18n', '../ui/gfx/gfx.gyp:gfx_geometry', + '../ui/gfx/ipc/geometry/gfx_ipc_geometry.gyp:gfx_ipc_geometry', '../ui/surface/surface.gyp:surface', 'ppapi.gyp:ppapi_c', 'ppapi_shared', @@ -221,6 +224,7 @@ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations_win64', '../gpu/gpu.gyp:command_buffer_common_win64', '../ipc/ipc.gyp:ipc_win64', + '../ui/gfx/gfx.gyp:gfx_geometry_win64', ], 'defines': [ '<@(nacl_win64_defines)', @@ -247,6 +251,7 @@ '../base/base.gyp:base_win64', '../ipc/ipc.gyp:ipc_win64', '../gpu/gpu.gyp:command_buffer_traits_win64', + '../ui/gfx/ipc/geometry/gfx_ipc_geometry.gyp:gfx_ipc_geometry_win64', 'ppapi.gyp:ppapi_c', 'ppapi_shared_win64', ],
diff --git a/ppapi/ppapi_proxy_nacl.gyp b/ppapi/ppapi_proxy_nacl.gyp index 1f194792..dd49bb30 100644 --- a/ppapi/ppapi_proxy_nacl.gyp +++ b/ppapi/ppapi_proxy_nacl.gyp
@@ -47,6 +47,8 @@ '../ppapi/ppapi_shared_nacl.gyp:ppapi_shared_nacl', '../third_party/WebKit/public/blink_headers.gyp:blink_headers', '../third_party/khronos/khronos.gyp:khronos_headers', + '../ui/gfx/gfx_nacl.gyp:gfx_geometry_nacl', + '../ui/gfx/ipc/geometry/gfx_ipc_geometry_nacl.gyp:gfx_ipc_geometry_nacl', ], }, ],
diff --git a/ppapi/ppapi_shared_nacl.gyp b/ppapi/ppapi_shared_nacl.gyp index 05e4aca..c292a34 100644 --- a/ppapi/ppapi_shared_nacl.gyp +++ b/ppapi/ppapi_shared_nacl.gyp
@@ -38,6 +38,7 @@ '../gpu/gpu_nacl.gyp:gles2_implementation_nacl', '../media/media_nacl.gyp:shared_memory_support_nacl', '../third_party/khronos/khronos.gyp:khronos_headers', + '../ui/gfx/gfx_nacl.gyp:gfx_geometry_nacl', ], }, ],
diff --git a/ppapi/proxy/BUILD.gn b/ppapi/proxy/BUILD.gn index fd36af7..b50b61a 100644 --- a/ppapi/proxy/BUILD.gn +++ b/ppapi/proxy/BUILD.gn
@@ -287,6 +287,8 @@ "//mojo/edk/system", "//ppapi/c", "//ppapi/shared_impl", + "//ui/gfx/geometry", + "//ui/gfx/ipc/geometry", ] if (!is_nacl) {
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index eaf2feb..968fe57 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h
@@ -1087,11 +1087,10 @@ // after this message is sent. IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer, ppapi::HostResource /* graphics_3d */) -IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBGraphics3D_SwapBuffers, +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBGraphics3D_SwapBuffers, ppapi::HostResource /* graphics_3d */, gpu::SyncToken /* sync_token */, - int32_t /* width*/, - int32_t /* height*/) + gfx::Size /* size */) IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBGraphics3D_EnsureWorkVisible, ppapi::HostResource /* context */)
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index ac08224..7725330b 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
@@ -48,8 +48,8 @@ } // namespace -Graphics3D::Graphics3D(const HostResource& resource) - : PPB_Graphics3D_Shared(resource) { +Graphics3D::Graphics3D(const HostResource& resource, const gfx::Size& size) + : PPB_Graphics3D_Shared(resource, size) { } Graphics3D::~Graphics3D() { @@ -118,8 +118,7 @@ } int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) { + const gfx::Size& size) { // A valid sync token would indicate a swap buffer already happened somehow. DCHECK(!sync_token.HasData()); @@ -137,8 +136,7 @@ gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData()); IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( - API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token, width, - height); + API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token, size); msg->set_unblock(true); PluginDispatcher::GetForResource(this)->Send(msg); @@ -215,7 +213,8 @@ if (result.is_null()) return 0; - scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); + scoped_refptr<Graphics3D> graphics_3d( + new Graphics3D(result, attrib_helper.offscreen_framebuffer_size)); if (!graphics_3d->Init(share_gles2, capabilities, shared_state, command_buffer_id)) { return 0; @@ -361,14 +360,13 @@ void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context, const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) { + const gfx::Size& size) { EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( context, callback_factory_, &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); if (enter.succeeded()) enter.SetResult(enter.object()->SwapBuffersWithSyncToken( - enter.callback(), sync_token, width, height)); + enter.callback(), sync_token, size)); } void PPB_Graphics3D_Proxy::OnMsgTakeFrontBuffer(const HostResource& context) {
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h index 2ae06e9..54c4c7a7 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.h +++ b/ppapi/proxy/ppb_graphics_3d_proxy.h
@@ -39,7 +39,7 @@ class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared { public: - explicit Graphics3D(const HostResource& resource); + Graphics3D(const HostResource& resource, const gfx::Size& size); ~Graphics3D() override; bool Init(gpu::gles2::GLES2Implementation* share_gles2, @@ -65,8 +65,7 @@ gpu::CommandBuffer* GetCommandBuffer() override; gpu::GpuControl* GetGpuControl() override; int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) override; + const gfx::Size& size) override; std::unique_ptr<PpapiCommandBufferProxy> command_buffer_; @@ -116,8 +115,7 @@ void OnMsgDestroyTransferBuffer(const HostResource& context, int32_t id); void OnMsgSwapBuffers(const HostResource& context, const gpu::SyncToken& sync_token, - int32_t width, - int32_t height); + const gfx::Size& size); void OnMsgTakeFrontBuffer(const HostResource& context); void OnMsgEnsureWorkVisible(const HostResource& context); // Renderer->plugin message handlers.
diff --git a/ppapi/proxy/video_decoder_resource_unittest.cc b/ppapi/proxy/video_decoder_resource_unittest.cc index a8e3c4fb..80c28035 100644 --- a/ppapi/proxy/video_decoder_resource_unittest.cc +++ b/ppapi/proxy/video_decoder_resource_unittest.cc
@@ -109,7 +109,7 @@ HostResource host_resource; host_resource.SetHostResource(pp_instance(), kGraphics3D); scoped_refptr<ppapi::proxy::Graphics3D> graphics_3d( - new ppapi::proxy::Graphics3D(host_resource)); + new ppapi::proxy::Graphics3D(host_resource, gfx::Size(640, 480))); return graphics_3d->GetReference(); }
diff --git a/ppapi/shared_impl/DEPS b/ppapi/shared_impl/DEPS index 3947af12..7f786933 100644 --- a/ppapi/shared_impl/DEPS +++ b/ppapi/shared_impl/DEPS
@@ -4,6 +4,7 @@ "+media/audio", "+media/base", "+skia", + "+ui/gfx/geometry", "-ppapi/cpp", "-ppapi/proxy",
diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc index 0c40b4cb..4d3a4b06 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.cc +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc
@@ -17,8 +17,9 @@ PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance) : Resource(OBJECT_IS_IMPL, instance) {} -PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource) - : Resource(OBJECT_IS_PROXY, host_resource) {} +PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource, + const gfx::Size& size) + : Resource(OBJECT_IS_PROXY, host_resource), size_(size) {} PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() { // Make sure that GLES2 implementation has already been destroyed. @@ -51,22 +52,20 @@ return PP_ERROR_BADARGUMENT; gles2_impl()->ResizeCHROMIUM(width, height, 1.f, true); - width_ = width; - height_ = height; + size_ = gfx::Size(width, height); // TODO(alokp): Check if resize succeeded and return appropriate error code. return PP_OK; } int32_t PPB_Graphics3D_Shared::SwapBuffers( scoped_refptr<TrackedCallback> callback) { - return SwapBuffersWithSyncToken(callback, gpu::SyncToken(), width_, height_); + return SwapBuffersWithSyncToken(callback, gpu::SyncToken(), size_); } int32_t PPB_Graphics3D_Shared::SwapBuffersWithSyncToken( scoped_refptr<TrackedCallback> callback, const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) { + const gfx::Size& size) { if (HasPendingSwap()) { Log(PP_LOGLEVEL_ERROR, "PPB_Graphics3D.SwapBuffers: Plugin attempted swap " @@ -76,7 +75,7 @@ } swap_callback_ = callback; - return DoSwapBuffers(sync_token, width, height); + return DoSwapBuffers(sync_token, size); } int32_t PPB_Graphics3D_Shared::GetAttribMaxValue(int32_t attribute,
diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.h b/ppapi/shared_impl/ppb_graphics_3d_shared.h index 4c8a1ab6..84bad21d 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.h +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.h
@@ -15,6 +15,7 @@ #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/ppb_graphics_3d_api.h" +#include "ui/gfx/geometry/size.h" namespace gpu { class CommandBuffer; @@ -44,8 +45,7 @@ int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override; int32_t SwapBuffersWithSyncToken(scoped_refptr<TrackedCallback> callback, const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) override; + const gfx::Size& size) override; int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) override; void* MapTexSubImage2DCHROMIUM(GLenum target, @@ -67,14 +67,14 @@ protected: PPB_Graphics3D_Shared(PP_Instance instance); - PPB_Graphics3D_Shared(const HostResource& host_resource); + PPB_Graphics3D_Shared(const HostResource& host_resource, + const gfx::Size& size); ~PPB_Graphics3D_Shared() override; virtual gpu::CommandBuffer* GetCommandBuffer() = 0; virtual gpu::GpuControl* GetGpuControl() = 0; virtual int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) = 0; + const gfx::Size& size) = 0; bool HasPendingSwap() const; bool CreateGLES2Impl(int32_t command_buffer_size, @@ -87,9 +87,9 @@ std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; std::unique_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; - // A local cache of the size of the viewport. - int32_t width_ = -1; - int32_t height_ = -1; + // A local cache of the size of the viewport. This is only valid in plugin + // resources. + gfx::Size size_; // Callback that needs to be executed when swap-buffers is completed. scoped_refptr<TrackedCallback> swap_callback_;
diff --git a/ppapi/thunk/ppb_graphics_3d_api.h b/ppapi/thunk/ppb_graphics_3d_api.h index 9c2e312..8d590ec9 100644 --- a/ppapi/thunk/ppb_graphics_3d_api.h +++ b/ppapi/thunk/ppb_graphics_3d_api.h
@@ -13,6 +13,10 @@ #include "ppapi/c/ppb_graphics_3d.h" #include "ppapi/thunk/ppapi_thunk_export.h" +namespace gfx { +class Size; +} + namespace gpu { struct SyncToken; } @@ -36,8 +40,7 @@ virtual int32_t SwapBuffersWithSyncToken( scoped_refptr<TrackedCallback> callback, const gpu::SyncToken& sync_token, - int32_t width, - int32_t height) = 0; + const gfx::Size& size) = 0; virtual int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) = 0; // Graphics3DTrusted API.
diff --git a/services/catalog/public/interfaces/catalog.mojom b/services/catalog/public/interfaces/catalog.mojom index beff6cbe..d9a0079 100644 --- a/services/catalog/public/interfaces/catalog.mojom +++ b/services/catalog/public/interfaces/catalog.mojom
@@ -12,6 +12,7 @@ interface Catalog { // Returns the catalog entries for the specified mojo names. // If |names| is null, all available entries are returned. + [Sync] GetEntries(array<string>? names) => (array<Entry> entries); // Returns the entry(ies) for applications that export to the caller the
diff --git a/services/ui/public/cpp/lib/command_buffer_client_impl.cc b/services/ui/public/cpp/lib/command_buffer_client_impl.cc index 3ca0993..928d1760 100644 --- a/services/ui/public/cpp/lib/command_buffer_client_impl.cc +++ b/services/ui/public/cpp/lib/command_buffer_client_impl.cc
@@ -40,16 +40,6 @@ return true; } -void MakeProgressCallback(gpu::CommandBuffer::State* output, - const gpu::CommandBuffer::State& input) { - *output = input; -} - -void InitializeCallback(ui::mojom::CommandBufferInitializeResultPtr* output, - ui::mojom::CommandBufferInitializeResultPtr input) { - *output = std::move(input); -} - } // namespace CommandBufferClientImpl::CommandBufferClientImpl( @@ -87,13 +77,11 @@ client_binding_.Bind(GetProxy(&client_ptr)); ui::mojom::CommandBufferInitializeResultPtr initialize_result; - command_buffer_->Initialize( - std::move(client_ptr), std::move(handle), - mojo::Array<int32_t>::From(attribs_), - base::Bind(&InitializeCallback, &initialize_result)); + result = command_buffer_->Initialize(std::move(client_ptr), std::move(handle), + mojo::Array<int32_t>::From(attribs_), + &initialize_result); - base::ThreadRestrictions::ScopedAllowWait wait; - if (!command_buffer_.WaitForIncomingResponse()) { + if (!result) { VLOG(1) << "Channel encountered error while creating command buffer."; return false; } @@ -289,11 +277,9 @@ void CommandBufferClientImpl::MakeProgressAndUpdateState() { gpu::CommandBuffer::State state; - command_buffer_->MakeProgress(last_state_.get_offset, - base::Bind(&MakeProgressCallback, &state)); + bool result = command_buffer_->MakeProgress(last_state_.get_offset, &state); - base::ThreadRestrictions::ScopedAllowWait wait; - if (!command_buffer_.WaitForIncomingResponse()) { + if (!result) { VLOG(1) << "Channel encountered error while waiting for command buffer."; // TODO(piman): is it ok for this to re-enter? Destroyed(gpu::error::kUnknown, gpu::error::kLostContext);
diff --git a/services/ui/public/interfaces/command_buffer.mojom b/services/ui/public/interfaces/command_buffer.mojom index 7e4a3c5..b38bcb8 100644 --- a/services/ui/public/interfaces/command_buffer.mojom +++ b/services/ui/public/interfaces/command_buffer.mojom
@@ -33,11 +33,13 @@ // If the context is lost after creation the LostContext method on the // CommandBufferClient's will be called then this pipe will be // closed. + [Sync] Initialize(CommandBufferClient client, handle<shared_buffer> shared_state, array<int32> attribs) => (CommandBufferInitializeResult? result); SetGetBuffer(int32 buffer); Flush(int32 put_offset); + [Sync] MakeProgress(int32 last_get_offset) => (gpu.mojom.CommandBufferState state); RegisterTransferBuffer( int32 id, handle<shared_buffer> transfer_buffer, uint32 size);