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

Side by Side Diff: mojo/edk/system/platform_handle_dispatcher.cc

Issue 728133002: Update mojo sdk to rev e01f9a49449381a5eb430c1fd88bf2cae73ec35a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + ios gyp fixes Created 6 years, 1 month 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
« no previous file with comments | « mojo/edk/system/options_validation.h ('k') | mojo/edk/system/raw_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/edk/system/platform_handle_dispatcher.h" 5 #include "mojo/edk/system/platform_handle_dispatcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 // static 38 // static
39 scoped_refptr<PlatformHandleDispatcher> PlatformHandleDispatcher::Deserialize( 39 scoped_refptr<PlatformHandleDispatcher> PlatformHandleDispatcher::Deserialize(
40 Channel* channel, 40 Channel* channel,
41 const void* source, 41 const void* source,
42 size_t size, 42 size_t size,
43 embedder::PlatformHandleVector* platform_handles) { 43 embedder::PlatformHandleVector* platform_handles) {
44 if (size != sizeof(SerializedPlatformHandleDispatcher)) { 44 if (size != sizeof(SerializedPlatformHandleDispatcher)) {
45 LOG(ERROR) << "Invalid serialized platform handle dispatcher (bad size)"; 45 LOG(ERROR) << "Invalid serialized platform handle dispatcher (bad size)";
46 return scoped_refptr<PlatformHandleDispatcher>(); 46 return nullptr;
47 } 47 }
48 48
49 const SerializedPlatformHandleDispatcher* serialization = 49 const SerializedPlatformHandleDispatcher* serialization =
50 static_cast<const SerializedPlatformHandleDispatcher*>(source); 50 static_cast<const SerializedPlatformHandleDispatcher*>(source);
51 size_t platform_handle_index = serialization->platform_handle_index; 51 size_t platform_handle_index = serialization->platform_handle_index;
52 52
53 // Starts off invalid, which is what we want. 53 // Starts off invalid, which is what we want.
54 embedder::PlatformHandle platform_handle; 54 embedder::PlatformHandle platform_handle;
55 55
56 if (platform_handle_index != kInvalidPlatformHandleIndex) { 56 if (platform_handle_index != kInvalidPlatformHandleIndex) {
57 if (!platform_handles || 57 if (!platform_handles ||
58 platform_handle_index >= platform_handles->size()) { 58 platform_handle_index >= platform_handles->size()) {
59 LOG(ERROR) 59 LOG(ERROR)
60 << "Invalid serialized platform handle dispatcher (missing handles)"; 60 << "Invalid serialized platform handle dispatcher (missing handles)";
61 return scoped_refptr<PlatformHandleDispatcher>(); 61 return nullptr;
62 } 62 }
63 63
64 // We take ownership of the handle, so we have to invalidate the one in 64 // We take ownership of the handle, so we have to invalidate the one in
65 // |platform_handles|. 65 // |platform_handles|.
66 std::swap(platform_handle, (*platform_handles)[platform_handle_index]); 66 std::swap(platform_handle, (*platform_handles)[platform_handle_index]);
67 } 67 }
68 68
69 return scoped_refptr<PlatformHandleDispatcher>(new PlatformHandleDispatcher( 69 return scoped_refptr<PlatformHandleDispatcher>(new PlatformHandleDispatcher(
70 embedder::ScopedPlatformHandle(platform_handle))); 70 embedder::ScopedPlatformHandle(platform_handle)));
71 } 71 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } else { 109 } else {
110 serialization->platform_handle_index = kInvalidPlatformHandleIndex; 110 serialization->platform_handle_index = kInvalidPlatformHandleIndex;
111 } 111 }
112 112
113 *actual_size = sizeof(SerializedPlatformHandleDispatcher); 113 *actual_size = sizeof(SerializedPlatformHandleDispatcher);
114 return true; 114 return true;
115 } 115 }
116 116
117 } // namespace system 117 } // namespace system
118 } // namespace mojo 118 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/options_validation.h ('k') | mojo/edk/system/raw_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698