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

Side by Side Diff: trunk/src/chrome/browser/ui/cocoa/run_loop_testing.mm

Issue 19737005: Revert 212948 "Made MessagePump a non-thread safe class." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/run_loop_testing.h" 5 #include "chrome/browser/ui/cocoa/run_loop_testing.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_pump_mac.h" 10 #include "base/message_loop/message_pump_mac.h"
12 11
13 // This class is scheduled with a delayed selector to quit the message pump. 12 // This class is scheduled with a delayed selector to quit the message pump.
14 @interface CocoaQuitTask : NSObject { 13 @interface CocoaQuitTask : NSObject {
15 @private 14 @private
16 base::MessagePumpNSRunLoop* pump_; 15 base::MessagePumpNSRunLoop* pump_;
17 } 16 }
18 - (id)initWithMessagePump:(base::MessagePumpNSRunLoop*)pump; 17 - (id)initWithMessagePump:(base::MessagePumpNSRunLoop*)pump;
19 - (void)doQuit; 18 - (void)doQuit;
20 @end 19 @end
(...skipping 10 matching lines...) Expand all
31 pump_->Quit(); 30 pump_->Quit();
32 } 31 }
33 @end 32 @end
34 33
35 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
36 35
37 namespace chrome { 36 namespace chrome {
38 namespace testing { 37 namespace testing {
39 38
40 void NSRunLoopRunAllPending() { 39 void NSRunLoopRunAllPending() {
41 scoped_ptr<base::MessagePumpNSRunLoop> message_pump( 40 scoped_refptr<base::MessagePumpNSRunLoop> message_pump(
42 new base::MessagePumpNSRunLoop); 41 new base::MessagePumpNSRunLoop);
43 42
44 // Put a delayed selector on the queue. All other pending delayed selectors 43 // Put a delayed selector on the queue. All other pending delayed selectors
45 // will run before this, after which the internal loop can end. 44 // will run before this, after which the internal loop can end.
46 base::scoped_nsobject<CocoaQuitTask> quit_task( 45 base::scoped_nsobject<CocoaQuitTask> quit_task(
47 [[CocoaQuitTask alloc] initWithMessagePump:message_pump.get()]); 46 [[CocoaQuitTask alloc] initWithMessagePump:message_pump.get()]);
48 47
49 [quit_task performSelector:@selector(doQuit) 48 [quit_task performSelector:@selector(doQuit)
50 withObject:nil 49 withObject:nil
51 afterDelay:0]; 50 afterDelay:0];
52 51
53 // Spin the internal loop, running it until the quit task is pumped. Pass NULL 52 // Spin the internal loop, running it until the quit task is pumped. Pass NULL
54 // because there is no delegate MessageLoop; only the Cocoa work queues will 53 // because there is no delegate MessageLoop; only the Cocoa work queues will
55 // be pumped. 54 // be pumped.
56 message_pump->Run(NULL); 55 message_pump->Run(NULL);
57 } 56 }
58 57
59 } // namespace testing 58 } // namespace testing
60 } // namespace chrome 59 } // namespace chrome
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/ui/cocoa/history_overlay_controller_unittest.mm ('k') | trunk/src/media/base/pipeline_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698