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

Side by Side Diff: base/message_pump_win.cc

Issue 2098020: Jankometer: Generalize the code more. Add better support for monitoring IO thread. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Address darin's comments. Created 10 years, 6 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
« no previous file with comments | « base/message_pump_win.h ('k') | base/tracked.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/message_pump_win.h" 5 #include "base/message_pump_win.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/win_util.h" 10 #include "base/win_util.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 490
491 if (ProcessInternalIOItem(item)) 491 if (ProcessInternalIOItem(item))
492 return true; 492 return true;
493 } 493 }
494 494
495 if (item.context->handler) { 495 if (item.context->handler) {
496 if (filter && item.handler != filter) { 496 if (filter && item.handler != filter) {
497 // Save this item for later 497 // Save this item for later
498 completed_io_.push_back(item); 498 completed_io_.push_back(item);
499 } else { 499 } else {
500 DCHECK(item.context->handler == item.handler); 500 DCHECK_EQ(item.context->handler, item.handler);
501 WillProcessIOEvent();
501 item.handler->OnIOCompleted(item.context, item.bytes_transfered, 502 item.handler->OnIOCompleted(item.context, item.bytes_transfered,
502 item.error); 503 item.error);
504 DidProcessIOEvent();
503 } 505 }
504 } else { 506 } else {
505 // The handler must be gone by now, just cleanup the mess. 507 // The handler must be gone by now, just cleanup the mess.
506 delete item.context; 508 delete item.context;
507 } 509 }
508 return true; 510 return true;
509 } 511 }
510 512
511 // Asks the OS for another IO completion result. 513 // Asks the OS for another IO completion result.
512 bool MessagePumpForIO::GetIOItem(DWORD timeout, IOItem* item) { 514 bool MessagePumpForIO::GetIOItem(DWORD timeout, IOItem* item) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 it != completed_io_.end(); ++it) { 546 it != completed_io_.end(); ++it) {
545 if (!filter || it->handler == filter) { 547 if (!filter || it->handler == filter) {
546 *item = *it; 548 *item = *it;
547 completed_io_.erase(it); 549 completed_io_.erase(it);
548 return true; 550 return true;
549 } 551 }
550 } 552 }
551 return false; 553 return false;
552 } 554 }
553 555
556 void MessagePumpForIO::AddIOObserver(IOObserver *obs) {
557 io_observers_.AddObserver(obs);
558 }
559
560 void MessagePumpForIO::RemoveIOObserver(IOObserver *obs) {
561 io_observers_.RemoveObserver(obs);
562 }
563
564 void MessagePumpForIO::WillProcessIOEvent() {
565 FOR_EACH_OBSERVER(IOObserver, io_observers_, WillProcessIOEvent());
566 }
567
568 void MessagePumpForIO::DidProcessIOEvent() {
569 FOR_EACH_OBSERVER(IOObserver, io_observers_, DidProcessIOEvent());
570 }
571
554 } // namespace base 572 } // namespace base
OLDNEW
« no previous file with comments | « base/message_pump_win.h ('k') | base/tracked.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698