Commit 8682e698 authored by Wez's avatar Wez Committed by Commit Bot

Revert synchronous FIDL callers to use SyncPtr rather than Sync2Ptr.

Sync2Ptr was a temporary type, used during migration of SyncPtr APIs
from returning |bool| to |zx_status_t|, to remove risk of implicit
conversions to |bool|.

Some libzx call-sites (e.g. use of zx::process::self()) are also
updated to be compatible with changes in the latest Fuchsia SDK.

TBR: dcheng, jochen
Change-Id: I9e9350931e18f2bddc0ef7234d225821cf7d22f1
Reviewed-on: https://chromium-review.googlesource.com/1141659
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576017}
parent 529fd118
...@@ -18,7 +18,7 @@ template <typename Interface> ...@@ -18,7 +18,7 @@ template <typename Interface>
class InterfacePtr; class InterfacePtr;
template <typename Interface> template <typename Interface>
class Synchronous2InterfacePtr; class SynchronousInterfacePtr;
} // namespace fidl } // namespace fidl
...@@ -49,8 +49,8 @@ class BASE_EXPORT ComponentContext { ...@@ -49,8 +49,8 @@ class BASE_EXPORT ComponentContext {
// Connects to an environment service and returns synchronous interface // Connects to an environment service and returns synchronous interface
// implementation. // implementation.
template <typename Interface> template <typename Interface>
fidl::Synchronous2InterfacePtr<Interface> ConnectToServiceSync() { fidl::SynchronousInterfacePtr<Interface> ConnectToServiceSync() {
fidl::Synchronous2InterfacePtr<Interface> result; fidl::SynchronousInterfacePtr<Interface> result;
ConnectToService(FidlInterfaceRequest(&result)); ConnectToService(FidlInterfaceRequest(&result));
return result; return result;
} }
......
...@@ -20,7 +20,7 @@ template <typename Interface> ...@@ -20,7 +20,7 @@ template <typename Interface>
class InterfacePtr; class InterfacePtr;
template <typename Interface> template <typename Interface>
class Synchronous2InterfacePtr; class SynchronousInterfacePtr;
} // namespace fidl } // namespace fidl
...@@ -46,7 +46,7 @@ class BASE_EXPORT FidlInterfaceRequest { ...@@ -46,7 +46,7 @@ class BASE_EXPORT FidlInterfaceRequest {
: FidlInterfaceRequest(stub->NewRequest()) {} : FidlInterfaceRequest(stub->NewRequest()) {}
template <typename Interface> template <typename Interface>
explicit FidlInterfaceRequest(fidl::Synchronous2InterfacePtr<Interface>* stub) explicit FidlInterfaceRequest(fidl::SynchronousInterfacePtr<Interface>* stub)
: FidlInterfaceRequest(stub->NewRequest()) {} : FidlInterfaceRequest(stub->NewRequest()) {}
FidlInterfaceRequest(FidlInterfaceRequest&&); FidlInterfaceRequest(FidlInterfaceRequest&&);
......
...@@ -325,8 +325,8 @@ void* CrashThread(void* arg) { ...@@ -325,8 +325,8 @@ void* CrashThread(void* arg) {
int death_location = data->death_location; int death_location = data->death_location;
// Register the exception handler on the port. // Register the exception handler on the port.
status = status = zx::thread::self()->bind_exception_port(*data->port,
zx::thread::self().bind_exception_port(*data->port, kExceptionPortKey, 0); kExceptionPortKey, 0);
if (status != ZX_OK) { if (status != ZX_OK) {
data->event->signal(0, ZX_USER_SIGNAL_0); data->event->signal(0, ZX_USER_SIGNAL_0);
return nullptr; return nullptr;
...@@ -374,8 +374,8 @@ void SpawnCrashThread(int death_location, uintptr_t* child_crash_addr) { ...@@ -374,8 +374,8 @@ void SpawnCrashThread(int death_location, uintptr_t* child_crash_addr) {
// Get the crash address. // Get the crash address.
zx::thread zircon_thread; zx::thread zircon_thread;
status = zx::process::self().get_child(packet.exception.tid, status = zx::process::self()->get_child(packet.exception.tid,
ZX_RIGHT_SAME_RIGHTS, &zircon_thread); ZX_RIGHT_SAME_RIGHTS, &zircon_thread);
ASSERT_EQ(status, ZX_OK); ASSERT_EQ(status, ZX_OK);
zx_thread_state_general_regs_t buffer; zx_thread_state_general_regs_t buffer;
status = zircon_thread.read_state(ZX_THREAD_STATE_GENERAL_REGS, &buffer, status = zircon_thread.read_state(ZX_THREAD_STATE_GENERAL_REGS, &buffer,
......
...@@ -88,7 +88,7 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) { ...@@ -88,7 +88,7 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) {
if (!read_only_) if (!read_only_)
flags |= ZX_VM_FLAG_PERM_WRITE; flags |= ZX_VM_FLAG_PERM_WRITE;
uintptr_t addr; uintptr_t addr;
zx_status_t status = zx::vmar::root_self().map( zx_status_t status = zx::vmar::root_self()->map(
0, *zx::unowned_vmo(shm_.GetHandle()), offset, bytes, flags, &addr); 0, *zx::unowned_vmo(shm_.GetHandle()), offset, bytes, flags, &addr);
if (status != ZX_OK) { if (status != ZX_OK) {
ZX_DLOG(ERROR, status) << "zx_vmar_map"; ZX_DLOG(ERROR, status) << "zx_vmar_map";
...@@ -109,7 +109,7 @@ bool SharedMemory::Unmap() { ...@@ -109,7 +109,7 @@ bool SharedMemory::Unmap() {
SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this); SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
uintptr_t addr = reinterpret_cast<uintptr_t>(memory_); uintptr_t addr = reinterpret_cast<uintptr_t>(memory_);
zx_status_t status = zx::vmar::root_self().unmap(addr, mapped_size_); zx_status_t status = zx::vmar::root_self()->unmap(addr, mapped_size_);
if (status != ZX_OK) { if (status != ZX_OK) {
ZX_DLOG(ERROR, status) << "zx_vmar_unmap"; ZX_DLOG(ERROR, status) << "zx_vmar_unmap";
return false; return false;
......
...@@ -417,7 +417,7 @@ TEST_P(SharedMemoryTest, GetReadOnlyHandle) { ...@@ -417,7 +417,7 @@ TEST_P(SharedMemoryTest, GetReadOnlyHandle) {
(void)handle; (void)handle;
#elif defined(OS_FUCHSIA) #elif defined(OS_FUCHSIA)
uintptr_t addr; uintptr_t addr;
EXPECT_NE(ZX_OK, zx::vmar::root_self().map( EXPECT_NE(ZX_OK, zx::vmar::root_self()->map(
0, *zx::unowned_vmo(handle.GetHandle()), 0, 0, *zx::unowned_vmo(handle.GetHandle()), 0,
contents.size(), ZX_VM_FLAG_PERM_WRITE, &addr)) contents.size(), ZX_VM_FLAG_PERM_WRITE, &addr))
<< "Shouldn't be able to map as writable."; << "Shouldn't be able to map as writable.";
......
...@@ -99,15 +99,15 @@ std::vector<NetworkInterface> NetInterfaceToNetworkInterfaces( ...@@ -99,15 +99,15 @@ std::vector<NetworkInterface> NetInterfaceToNetworkInterfaces(
bool GetNetworkList(NetworkInterfaceList* networks, int policy) { bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
DCHECK(networks); DCHECK(networks);
fuchsia::netstack::NetstackSync2Ptr netstack = fuchsia::netstack::NetstackSyncPtr netstack =
base::fuchsia::ComponentContext::GetDefault() base::fuchsia::ComponentContext::GetDefault()
->ConnectToServiceSync<fuchsia::netstack::Netstack>(); ->ConnectToServiceSync<fuchsia::netstack::Netstack>();
// TODO(kmarshall): Use NetworkChangeNotifier's cached interface list. // TODO(kmarshall): Use NetworkChangeNotifier's cached interface list.
fidl::VectorPtr<fuchsia::netstack::NetInterface> interfaces; fidl::VectorPtr<fuchsia::netstack::NetInterface> interfaces;
auto status = netstack->GetInterfaces(&interfaces); zx_status_t status = netstack->GetInterfaces(&interfaces);
if (status.statvs != ZX_OK) { if (status != ZX_OK) {
ZX_LOG(ERROR, status.statvs) << "fuchsia::netstack::GetInterfaces()"; ZX_LOG(ERROR, status) << "fuchsia::netstack::GetInterfaces()";
return false; return false;
} }
......
...@@ -204,7 +204,7 @@ void FuchsiaFontManager::FontCache::OnTypefaceDeleted(zx_koid_t vmo_koid) { ...@@ -204,7 +204,7 @@ void FuchsiaFontManager::FontCache::OnTypefaceDeleted(zx_koid_t vmo_koid) {
} }
FuchsiaFontManager::FuchsiaFontManager( FuchsiaFontManager::FuchsiaFontManager(
fuchsia::fonts::FontProviderSync2Ptr font_provider) fuchsia::fonts::FontProviderSyncPtr font_provider)
: font_provider_(std::move(font_provider)), font_cache_(new FontCache()) { : font_provider_(std::move(font_provider)), font_cache_(new FontCache()) {
for (auto& m : kFontMap) { for (auto& m : kFontMap) {
font_map_[m.font_name_in] = m.font_name_out; font_map_[m.font_name_in] = m.font_name_out;
...@@ -254,9 +254,9 @@ SkTypeface* FuchsiaFontManager::onMatchFamilyStyle( ...@@ -254,9 +254,9 @@ SkTypeface* FuchsiaFontManager::onMatchFamilyStyle(
request.slant = ToFontSlant(style.slant()); request.slant = ToFontSlant(style.slant());
fuchsia::fonts::FontResponsePtr response; fuchsia::fonts::FontResponsePtr response;
auto status = font_provider_->GetFont(std::move(request), &response); zx_status_t status = font_provider_->GetFont(std::move(request), &response);
if (status.statvs != ZX_OK) { if (status != ZX_OK) {
ZX_DLOG(ERROR, status.statvs) << "Failed to query font provider."; ZX_DLOG(ERROR, status) << "Failed to query font provider.";
} else if (response) { } else if (response) {
sk_sp<SkTypeface> result = sk_sp<SkTypeface> result =
font_cache_->GetTypefaceFromFontData(std::move(response->data)); font_cache_->GetTypefaceFromFontData(std::move(response->data));
......
...@@ -20,7 +20,7 @@ namespace skia { ...@@ -20,7 +20,7 @@ namespace skia {
class SK_API FuchsiaFontManager : public SkFontMgr { class SK_API FuchsiaFontManager : public SkFontMgr {
public: public:
explicit FuchsiaFontManager( explicit FuchsiaFontManager(
fuchsia::fonts::FontProviderSync2Ptr font_provider); fuchsia::fonts::FontProviderSyncPtr font_provider);
~FuchsiaFontManager() override; ~FuchsiaFontManager() override;
...@@ -52,7 +52,7 @@ class SK_API FuchsiaFontManager : public SkFontMgr { ...@@ -52,7 +52,7 @@ class SK_API FuchsiaFontManager : public SkFontMgr {
private: private:
class FontCache; class FontCache;
fuchsia::fonts::FontProviderSync2Ptr font_provider_; fuchsia::fonts::FontProviderSyncPtr font_provider_;
// Map applied to font family name before sending requests to the FontService. // Map applied to font family name before sending requests to the FontService.
base::flat_map<std::string, std::string> font_map_; base::flat_map<std::string, std::string> font_map_;
......
...@@ -115,7 +115,7 @@ class MockFontProviderService { ...@@ -115,7 +115,7 @@ class MockFontProviderService {
class FuchsiaFontManagerTest : public testing::Test { class FuchsiaFontManagerTest : public testing::Test {
public: public:
FuchsiaFontManagerTest() { FuchsiaFontManagerTest() {
fuchsia::fonts::FontProviderSync2Ptr font_provider; fuchsia::fonts::FontProviderSyncPtr font_provider;
font_provider_service_.Bind(font_provider.NewRequest()); font_provider_service_.Bind(font_provider.NewRequest());
font_manager_ = sk_make_sp<FuchsiaFontManager>(std::move(font_provider)); font_manager_ = sk_make_sp<FuchsiaFontManager>(std::move(font_provider));
} }
...@@ -160,4 +160,4 @@ TEST_F(FuchsiaFontManagerTest, ReleaseThenCreateAgain) { ...@@ -160,4 +160,4 @@ TEST_F(FuchsiaFontManagerTest, ReleaseThenCreateAgain) {
EXPECT_TRUE(serif2); EXPECT_TRUE(serif2);
} }
} // namespace skia } // namespace skia
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment