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

Side by Side Diff: content/renderer/media/scoped_loop_observer.h

Issue 10383262: RefCounted types should not have public destructors, delegate cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make win bot happy Created 8 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) 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 #ifndef CONTENT_RENDERER_MEDIA_SCOPED_LOOP_OBSERVER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_SCOPED_LOOP_OBSERVER_H_
6 #define CONTENT_RENDERER_MEDIA_SCOPED_LOOP_OBSERVER_H_ 6 #define CONTENT_RENDERER_MEDIA_SCOPED_LOOP_OBSERVER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 12
13 namespace base { 13 namespace base {
14 class WaitableEvent; 14 class WaitableEvent;
15 } 15 }
16 16
17 // A common base class for AudioDevice and AudioInputDevice that manages 17 // A common base class for AudioDevice and AudioInputDevice that manages
18 // a message loop pointer and monitors it for destruction. If the object goes 18 // a message loop pointer and monitors it for destruction. If the object goes
19 // out of scope before the message loop, the object will automatically remove 19 // out of scope before the message loop, the object will automatically remove
20 // itself from the message loop's list of destruction observers. 20 // itself from the message loop's list of destruction observers.
21 // NOTE: The class that inherits from this class must implement the 21 // NOTE: The class that inherits from this class must implement the
22 // WillDestroyCurrentMessageLoop virtual method from DestructionObserver. 22 // WillDestroyCurrentMessageLoop virtual method from DestructionObserver.
23 class ScopedLoopObserver 23 class ScopedLoopObserver
24 : public MessageLoop::DestructionObserver { 24 : public MessageLoop::DestructionObserver {
25 public: 25 public:
26 explicit ScopedLoopObserver(MessageLoop* message_loop); 26 explicit ScopedLoopObserver(MessageLoop* message_loop);
27
28 protected:
27 virtual ~ScopedLoopObserver(); 29 virtual ~ScopedLoopObserver();
28 30
29 protected:
30 // Accessor to the loop that's used by the derived class. 31 // Accessor to the loop that's used by the derived class.
31 base::MessageLoopProxy* message_loop() { return loop_; } 32 base::MessageLoopProxy* message_loop() { return loop_; }
32 33
33 private: 34 private:
34 // Call to add or remove ourselves from the list of destruction observers for 35 // Call to add or remove ourselves from the list of destruction observers for
35 // the message loop. 36 // the message loop.
36 void ObserveLoopDestruction(bool enable, base::WaitableEvent* done); 37 void ObserveLoopDestruction(bool enable, base::WaitableEvent* done);
37 38
38 // A pointer to the message loop's proxy. In case the loop gets destroyed 39 // A pointer to the message loop's proxy. In case the loop gets destroyed
39 // before this object goes out of scope, PostTask etc will fail but not crash. 40 // before this object goes out of scope, PostTask etc will fail but not crash.
40 scoped_refptr<base::MessageLoopProxy> loop_; 41 scoped_refptr<base::MessageLoopProxy> loop_;
41 42
42 DISALLOW_COPY_AND_ASSIGN(ScopedLoopObserver); 43 DISALLOW_COPY_AND_ASSIGN(ScopedLoopObserver);
43 }; 44 };
44 45
45 #endif // CONTENT_RENDERER_MEDIA_SCOPED_LOOP_OBSERVER_H_ 46 #endif // CONTENT_RENDERER_MEDIA_SCOPED_LOOP_OBSERVER_H_
OLDNEW
« no previous file with comments | « content/public/renderer/render_view.h ('k') | content/renderer/pepper/pepper_parent_context_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698