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

Side by Side Diff: mojo/public/bindings/js/core.cc

Issue 64623003: Fix win64 build failure on size truncation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/public/tests/bindings_connector_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/public/bindings/js/core.h" 5 #include "mojo/public/bindings/js/core.h"
6 6
7 #include "gin/arguments.h" 7 #include "gin/arguments.h"
8 #include "gin/array_buffer.h" 8 #include "gin/array_buffer.h"
9 #include "gin/converter.h" 9 #include "gin/converter.h"
10 #include "gin/dictionary.h" 10 #include "gin/dictionary.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (!args.GetNext(&handles) || 53 if (!args.GetNext(&handles) ||
54 !args.GetNext(&flags) || 54 !args.GetNext(&flags) ||
55 !args.GetNext(&deadline)) { 55 !args.GetNext(&deadline)) {
56 return args.ThrowError(); 56 return args.ThrowError();
57 } 57 }
58 58
59 if (handles.size() != flags.size()) 59 if (handles.size() != flags.size())
60 return args.ThrowTypeError("Arrays must have the same length."); 60 return args.ThrowTypeError("Arrays must have the same length.");
61 61
62 args.Return(mojo::WaitMany(handles.data(), flags.data(), 62 args.Return(mojo::WaitMany(handles.data(), flags.data(),
63 handles.size(), deadline)); 63 static_cast<uint32_t>(handles.size()), deadline));
64 } 64 }
65 65
66 void CreateMessagePipe(const v8::FunctionCallbackInfo<v8::Value>& info) { 66 void CreateMessagePipe(const v8::FunctionCallbackInfo<v8::Value>& info) {
67 gin::Arguments args(info); 67 gin::Arguments args(info);
68 68
69 mojo::Handle handle_0 = mojo::kInvalidHandle; 69 mojo::Handle handle_0 = mojo::kInvalidHandle;
70 mojo::Handle handle_1 = mojo::kInvalidHandle; 70 mojo::Handle handle_1 = mojo::kInvalidHandle;
71 MojoResult result = mojo::CreateMessagePipe(&handle_0, &handle_1); 71 MojoResult result = mojo::CreateMessagePipe(&handle_0, &handle_1);
72 72
73 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(info.GetIsolate()); 73 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(info.GetIsolate());
(...skipping 11 matching lines...) Expand all
85 std::vector<mojo::Handle> handles; 85 std::vector<mojo::Handle> handles;
86 MojoWriteMessageFlags flags = MOJO_WRITE_MESSAGE_FLAG_NONE; 86 MojoWriteMessageFlags flags = MOJO_WRITE_MESSAGE_FLAG_NONE;
87 87
88 if (!args.GetNext(&handle) || 88 if (!args.GetNext(&handle) ||
89 !args.GetNext(&buffer) || 89 !args.GetNext(&buffer) ||
90 !args.GetNext(&handles) || 90 !args.GetNext(&handles) ||
91 !args.GetNext(&flags)) { 91 !args.GetNext(&flags)) {
92 return args.ThrowError(); 92 return args.ThrowError();
93 } 93 }
94 94
95 args.Return(mojo::WriteMessage(handle, buffer.bytes(), buffer.num_bytes(), 95 args.Return(mojo::WriteMessage(handle, buffer.bytes(),
96 handles.data(), handles.size(), flags)); 96 static_cast<uint32_t>(buffer.num_bytes()),
97 handles.data(),
98 static_cast<uint32_t>(handles.size()),
99 flags));
97 } 100 }
98 101
99 void ReadMessage(const v8::FunctionCallbackInfo<v8::Value>& info) { 102 void ReadMessage(const v8::FunctionCallbackInfo<v8::Value>& info) {
100 gin::Arguments args(info); 103 gin::Arguments args(info);
101 104
102 mojo::Handle handle = mojo::kInvalidHandle; 105 mojo::Handle handle = mojo::kInvalidHandle;
103 gin::ArrayBufferView buffer(args.isolate()); 106 gin::ArrayBufferView buffer(args.isolate());
104 uint32_t num_handles = 0; 107 uint32_t num_handles = 0;
105 MojoReadMessageFlags flags = MOJO_READ_MESSAGE_FLAG_NONE; 108 MojoReadMessageFlags flags = MOJO_READ_MESSAGE_FLAG_NONE;
106 109
107 if (!args.GetNext(&handle) || 110 if (!args.GetNext(&handle) ||
108 !args.GetNext(&buffer) || 111 !args.GetNext(&buffer) ||
109 !args.GetNext(&num_handles) || 112 !args.GetNext(&num_handles) ||
110 !args.GetNext(&flags)) { 113 !args.GetNext(&flags)) {
111 return args.ThrowError(); 114 return args.ThrowError();
112 } 115 }
113 116
114 uint32_t num_bytes = buffer.num_bytes(); 117 uint32_t num_bytes = static_cast<uint32_t>(buffer.num_bytes());
115 std::vector<mojo::Handle> handles(num_handles); 118 std::vector<mojo::Handle> handles(num_handles);
116 MojoResult result = mojo::ReadMessage(handle, buffer.bytes(), &num_bytes, 119 MojoResult result = mojo::ReadMessage(handle, buffer.bytes(), &num_bytes,
117 handles.data(), &num_handles, flags); 120 handles.data(), &num_handles, flags);
118 handles.resize(num_handles); 121 handles.resize(num_handles);
119 122
120 // TODO(abarth): We should benchmark this codepath to make sure it's ok to 123 // TODO(abarth): We should benchmark this codepath to make sure it's ok to
121 // allocate all this memory on each read. 124 // allocate all this memory on each read.
122 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(info.GetIsolate()); 125 gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(info.GetIsolate());
123 dictionary.Set("result", result); 126 dictionary.Set("result", result);
124 dictionary.Set("bytesRead", num_bytes); 127 dictionary.Set("bytesRead", num_bytes);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 gin::ConvertToV8(isolate, MOJO_READ_MESSAGE_FLAG_MAY_DISCARD)); 208 gin::ConvertToV8(isolate, MOJO_READ_MESSAGE_FLAG_MAY_DISCARD));
206 209
207 data->SetObjectTemplate(&g_core_wrapper_info, templ); 210 data->SetObjectTemplate(&g_core_wrapper_info, templ);
208 } 211 }
209 212
210 return templ; 213 return templ;
211 } 214 }
212 215
213 } // namespace js 216 } // namespace js
214 } // namespace mojo 217 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tests/bindings_connector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698