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

Side by Side Diff: base/message_pump_glib_unittest.cc

Issue 360042: First patch in making destructors of refcounted objects private. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_glib.h" 5 #include "base/message_pump_glib.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <math.h> 8 #include <math.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } else { 323 } else {
324 injector_->AddEvent( 324 injector_->AddEvent(
325 0, NewRunnableMethod(this, &ConcurrentHelper::FromEvent)); 325 0, NewRunnableMethod(this, &ConcurrentHelper::FromEvent));
326 } 326 }
327 } 327 }
328 328
329 int event_count() const { return event_count_; } 329 int event_count() const { return event_count_; }
330 int task_count() const { return task_count_; } 330 int task_count() const { return task_count_; }
331 331
332 private: 332 private:
333 friend class base::RefCounted<ConcurrentHelper>;
334
335 ~ConcurrentHelper() {}
336
333 static const int kStartingEventCount = 20; 337 static const int kStartingEventCount = 20;
334 static const int kStartingTaskCount = 20; 338 static const int kStartingTaskCount = 20;
335 339
336 EventInjector* injector_; 340 EventInjector* injector_;
337 int event_count_; 341 int event_count_;
338 int task_count_; 342 int task_count_;
339 }; 343 };
340 344
341 } // namespace 345 } // namespace
342 346
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 452
449 void Quit() { 453 void Quit() {
450 quit_ = true; 454 quit_ = true;
451 } 455 }
452 456
453 void Reset() { 457 void Reset() {
454 quit_ = false; 458 quit_ = false;
455 } 459 }
456 460
457 private: 461 private:
462 friend class base::RefCounted<GLibLoopRunner>;
463
464 ~GLibLoopRunner() {}
465
458 bool quit_; 466 bool quit_;
459 }; 467 };
460 468
461 void TestGLibLoopInternal(EventInjector* injector) { 469 void TestGLibLoopInternal(EventInjector* injector) {
462 // Allow tasks to be processed from 'native' event loops. 470 // Allow tasks to be processed from 'native' event loops.
463 MessageLoop::current()->SetNestableTasksAllowed(true); 471 MessageLoop::current()->SetNestableTasksAllowed(true);
464 scoped_refptr<GLibLoopRunner> runner = new GLibLoopRunner(); 472 scoped_refptr<GLibLoopRunner> runner = new GLibLoopRunner();
465 473
466 int task_count = 0; 474 int task_count = 0;
467 // Add a couple of dummy events 475 // Add a couple of dummy events
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 542
535 TEST_F(MessagePumpGLibTest, TestGtkLoop) { 543 TEST_F(MessagePumpGLibTest, TestGtkLoop) {
536 // Tests that events and posted tasks are correctly exectuted if the message 544 // Tests that events and posted tasks are correctly exectuted if the message
537 // loop is not run by MessageLoop::Run() but by a straight Gtk loop. 545 // loop is not run by MessageLoop::Run() but by a straight Gtk loop.
538 // Note that in this case we don't make strong guarantees about niceness 546 // Note that in this case we don't make strong guarantees about niceness
539 // between events and posted tasks. 547 // between events and posted tasks.
540 loop()->PostTask(FROM_HERE, 548 loop()->PostTask(FROM_HERE,
541 NewRunnableFunction(TestGtkLoopInternal, injector())); 549 NewRunnableFunction(TestGtkLoopInternal, injector()));
542 loop()->Run(); 550 loop()->Run();
543 } 551 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698