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

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

Issue 1403033003: Last set of fixes to make the src/mojo/edk pass the page cycler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another small fix Created 5 years, 2 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 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/edk/system/data_pipe_producer_dispatcher.h" 5 #include "mojo/edk/system/data_pipe_producer_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/edk/embedder/embedder_internal.h" 10 #include "mojo/edk/embedder/embedder_internal.h"
11 #include "mojo/edk/embedder/platform_shared_buffer.h" 11 #include "mojo/edk/embedder/platform_shared_buffer.h"
12 #include "mojo/edk/embedder/platform_support.h" 12 #include "mojo/edk/embedder/platform_support.h"
13 #include "mojo/edk/system/configuration.h" 13 #include "mojo/edk/system/configuration.h"
14 #include "mojo/edk/system/data_pipe.h" 14 #include "mojo/edk/system/data_pipe.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace edk { 17 namespace edk {
18 18
19 void DataPipeProducerDispatcher::Init( 19 void DataPipeProducerDispatcher::Init(
20 ScopedPlatformHandle message_pipe, 20 ScopedPlatformHandle message_pipe,
21 char* serialized_write_buffer, size_t serialized_write_buffer_size) { 21 char* serialized_write_buffer, size_t serialized_write_buffer_size) {
22 if (message_pipe.is_valid()) { 22 if (message_pipe.is_valid()) {
23 channel_ = RawChannel::Create(message_pipe.Pass()); 23 channel_ = RawChannel::Create(message_pipe.Pass());
24 channel_->SetSerializedData( 24 channel_->SetSerializedData(
25 nullptr, 0u, serialized_write_buffer, serialized_write_buffer_size); 25 nullptr, 0u, serialized_write_buffer, serialized_write_buffer_size);
26 internal::g_io_thread_task_runner->PostTask( 26 internal::g_io_thread_task_runner->PostTask(
27 FROM_HERE, base::Bind(&DataPipeProducerDispatcher::InitOnIO, this)); 27 FROM_HERE, base::Bind(&DataPipeProducerDispatcher::InitOnIO, this));
28 } else {
29 error_ = true;
28 } 30 }
29 } 31 }
30 32
31 void DataPipeProducerDispatcher::InitOnIO() { 33 void DataPipeProducerDispatcher::InitOnIO() {
32 base::AutoLock locker(lock()); 34 base::AutoLock locker(lock());
33 if (channel_) 35 if (channel_)
34 channel_->Init(this); 36 channel_->Init(this);
35 } 37 }
36 38
37 void DataPipeProducerDispatcher::CloseOnIO() { 39 void DataPipeProducerDispatcher::CloseOnIO() {
(...skipping 27 matching lines...) Expand all
65 scoped_refptr<PlatformSharedBuffer> shared_buffer; 67 scoped_refptr<PlatformSharedBuffer> shared_buffer;
66 scoped_ptr<PlatformSharedBufferMapping> mapping; 68 scoped_ptr<PlatformSharedBufferMapping> mapping;
67 if (shared_memory_size) { 69 if (shared_memory_size) {
68 shared_buffer = internal::g_platform_support->CreateSharedBufferFromHandle( 70 shared_buffer = internal::g_platform_support->CreateSharedBufferFromHandle(
69 shared_memory_size, shared_memory_handle.Pass()); 71 shared_memory_size, shared_memory_handle.Pass());
70 mapping = shared_buffer->Map(0, shared_memory_size); 72 mapping = shared_buffer->Map(0, shared_memory_size);
71 serialized_write_buffer = static_cast<char*>(mapping->GetBase()); 73 serialized_write_buffer = static_cast<char*>(mapping->GetBase());
72 serialized_write_buffer_size = shared_memory_size; 74 serialized_write_buffer_size = shared_memory_size;
73 } 75 }
74 76
75 if (platform_handle.is_valid()) { 77 rv->Init(platform_handle.Pass(), serialized_write_buffer,
76 rv->Init(platform_handle.Pass(), serialized_write_buffer, 78 serialized_write_buffer_size);
77 serialized_write_buffer_size);
78 }
79 return rv; 79 return rv;
80 } 80 }
81 81
82 DataPipeProducerDispatcher::DataPipeProducerDispatcher( 82 DataPipeProducerDispatcher::DataPipeProducerDispatcher(
83 const MojoCreateDataPipeOptions& options) 83 const MojoCreateDataPipeOptions& options)
84 : options_(options), channel_(nullptr), error_(false) { 84 : options_(options), channel_(nullptr), error_(false) {
85 } 85 }
86 86
87 DataPipeProducerDispatcher::~DataPipeProducerDispatcher() { 87 DataPipeProducerDispatcher::~DataPipeProducerDispatcher() {
88 // |Close()|/|CloseImplNoLock()| should have taken care of the channel. 88 // |Close()|/|CloseImplNoLock()| should have taken care of the channel.
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 374
375 offset += message_num_bytes; 375 offset += message_num_bytes;
376 } 376 }
377 377
378 return true; 378 return true;
379 } 379 }
380 380
381 } // namespace edk 381 } // namespace edk
382 } // namespace mojo 382 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698