OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ipc/ipc_channel_reader.h" | 5 #include "ipc/ipc_channel_reader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
| 11 #include "base/logging.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" |
12 #include "ipc/ipc_listener.h" | 14 #include "ipc/ipc_listener.h" |
13 #include "ipc/ipc_logging.h" | 15 #include "ipc/ipc_logging.h" |
14 #include "ipc/ipc_message.h" | 16 #include "ipc/ipc_message.h" |
15 #include "ipc/ipc_message_attachment_set.h" | 17 #include "ipc/ipc_message_attachment_set.h" |
16 #include "ipc/ipc_message_macros.h" | 18 #include "ipc/ipc_message_macros.h" |
17 | 19 |
18 namespace IPC { | 20 namespace IPC { |
19 namespace internal { | 21 namespace internal { |
20 | 22 |
21 #ifdef IPC_MESSAGE_LOG_ENABLED | 23 #ifdef IPC_MESSAGE_LOG_ENABLED |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 blocked_ids_.erase(it); | 317 blocked_ids_.erase(it); |
316 | 318 |
317 if (blocked_ids_.empty()) { | 319 if (blocked_ids_.empty()) { |
318 StopObservingAttachmentBroker(); | 320 StopObservingAttachmentBroker(); |
319 DispatchMessages(); | 321 DispatchMessages(); |
320 } | 322 } |
321 } | 323 } |
322 | 324 |
323 void ChannelReader::StartObservingAttachmentBroker() { | 325 void ChannelReader::StartObservingAttachmentBroker() { |
324 #if USE_ATTACHMENT_BROKER | 326 #if USE_ATTACHMENT_BROKER |
325 GetAttachmentBroker()->AddObserver( | 327 DCHECK(base::MessageLoopForIO::IsCurrent()); |
326 this, base::MessageLoopForIO::current()->task_runner()); | 328 GetAttachmentBroker()->AddObserver(this, base::ThreadTaskRunnerHandle::Get()); |
327 #endif // USE_ATTACHMENT_BROKER | 329 #endif // USE_ATTACHMENT_BROKER |
328 } | 330 } |
329 | 331 |
330 void ChannelReader::StopObservingAttachmentBroker() { | 332 void ChannelReader::StopObservingAttachmentBroker() { |
331 #if USE_ATTACHMENT_BROKER | 333 #if USE_ATTACHMENT_BROKER |
332 GetAttachmentBroker()->RemoveObserver(this); | 334 GetAttachmentBroker()->RemoveObserver(this); |
333 #endif // USE_ATTACHMENT_BROKER | 335 #endif // USE_ATTACHMENT_BROKER |
334 } | 336 } |
335 | 337 |
336 bool ChannelReader::CheckMessageSize(size_t size) { | 338 bool ChannelReader::CheckMessageSize(size_t size) { |
337 if (size <= Channel::kMaximumMessageSize) { | 339 if (size <= Channel::kMaximumMessageSize) { |
338 return true; | 340 return true; |
339 } | 341 } |
340 input_overflow_buf_.clear(); | 342 input_overflow_buf_.clear(); |
341 LOG(ERROR) << "IPC message is too big: " << size; | 343 LOG(ERROR) << "IPC message is too big: " << size; |
342 return false; | 344 return false; |
343 } | 345 } |
344 | 346 |
345 } // namespace internal | 347 } // namespace internal |
346 } // namespace IPC | 348 } // namespace IPC |
OLD | NEW |