Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: components/exo/wayland/server.cc

Issue 2843113002: make base::SharedMemoryHandle a class on POSIX. (Closed)
Patch Set: Fix test error. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/exo/wayland/server.h" 5 #include "components/exo/wayland/server.h"
6 6
7 #include <alpha-compositing-unstable-v1-server-protocol.h> 7 #include <alpha-compositing-unstable-v1-server-protocol.h>
8 #include <gaming-input-unstable-v1-server-protocol.h> 8 #include <gaming-input-unstable-v1-server-protocol.h>
9 #include <gaming-input-unstable-v2-server-protocol.h> 9 #include <gaming-input-unstable-v2-server-protocol.h>
10 #include <grp.h> 10 #include <grp.h>
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 //////////////////////////////////////////////////////////////////////////////// 436 ////////////////////////////////////////////////////////////////////////////////
437 // wl_shm_interface: 437 // wl_shm_interface:
438 438
439 void shm_create_pool(wl_client* client, 439 void shm_create_pool(wl_client* client,
440 wl_resource* resource, 440 wl_resource* resource,
441 uint32_t id, 441 uint32_t id,
442 int fd, 442 int fd,
443 int32_t size) { 443 int32_t size) {
444 std::unique_ptr<SharedMemory> shared_memory = 444 std::unique_ptr<SharedMemory> shared_memory =
445 GetUserDataAs<Display>(resource)->CreateSharedMemory( 445 GetUserDataAs<Display>(resource)->CreateSharedMemory(
446 base::FileDescriptor(fd, true), size); 446 base::SharedMemoryHandle::ImportHandle(fd), size);
447 if (!shared_memory) { 447 if (!shared_memory) {
448 wl_resource_post_no_memory(resource); 448 wl_resource_post_no_memory(resource);
449 return; 449 return;
450 } 450 }
451 451
452 wl_resource* shm_pool_resource = 452 wl_resource* shm_pool_resource =
453 wl_resource_create(client, &wl_shm_pool_interface, 1, id); 453 wl_resource_create(client, &wl_shm_pool_interface, 1, id);
454 454
455 SetImplementation(shm_pool_resource, &shm_pool_implementation, 455 SetImplementation(shm_pool_resource, &shm_pool_implementation,
456 std::move(shared_memory)); 456 std::move(shared_memory));
(...skipping 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 std::unique_ptr<char, base::FreeDeleter> keymap_string( 2742 std::unique_ptr<char, base::FreeDeleter> keymap_string(
2743 xkb_keymap_get_as_string(xkb_keymap_.get(), XKB_KEYMAP_FORMAT_TEXT_V1)); 2743 xkb_keymap_get_as_string(xkb_keymap_.get(), XKB_KEYMAP_FORMAT_TEXT_V1));
2744 DCHECK(keymap_string.get()); 2744 DCHECK(keymap_string.get());
2745 size_t keymap_size = strlen(keymap_string.get()) + 1; 2745 size_t keymap_size = strlen(keymap_string.get()) + 1;
2746 base::SharedMemory shared_keymap; 2746 base::SharedMemory shared_keymap;
2747 bool rv = shared_keymap.CreateAndMapAnonymous(keymap_size); 2747 bool rv = shared_keymap.CreateAndMapAnonymous(keymap_size);
2748 DCHECK(rv); 2748 DCHECK(rv);
2749 memcpy(shared_keymap.memory(), keymap_string.get(), keymap_size); 2749 memcpy(shared_keymap.memory(), keymap_string.get(), keymap_size);
2750 wl_keyboard_send_keymap(keyboard_resource_, 2750 wl_keyboard_send_keymap(keyboard_resource_,
2751 WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, 2751 WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
2752 shared_keymap.handle().fd, keymap_size); 2752 shared_keymap.handle().GetHandle(), keymap_size);
2753 } 2753 }
2754 2754
2755 // Overridden from KeyboardDelegate: 2755 // Overridden from KeyboardDelegate:
2756 void OnKeyboardDestroying(Keyboard* keyboard) override { delete this; } 2756 void OnKeyboardDestroying(Keyboard* keyboard) override { delete this; }
2757 bool CanAcceptKeyboardEventsForSurface(Surface* surface) const override { 2757 bool CanAcceptKeyboardEventsForSurface(Surface* surface) const override {
2758 wl_resource* surface_resource = GetSurfaceResource(surface); 2758 wl_resource* surface_resource = GetSurfaceResource(surface);
2759 // We can accept events for this surface if the client is the same as the 2759 // We can accept events for this surface if the client is the same as the
2760 // keyboard. 2760 // keyboard.
2761 return surface_resource && 2761 return surface_resource &&
2762 wl_resource_get_client(surface_resource) == client(); 2762 wl_resource_get_client(surface_resource) == client();
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 DCHECK(event_loop); 3956 DCHECK(event_loop);
3957 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 3957 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
3958 } 3958 }
3959 3959
3960 void Server::Flush() { 3960 void Server::Flush() {
3961 wl_display_flush_clients(wl_display_.get()); 3961 wl_display_flush_clients(wl_display_.get());
3962 } 3962 }
3963 3963
3964 } // namespace wayland 3964 } // namespace wayland
3965 } // namespace exo 3965 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698