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

Side by Side Diff: media/base/callback.h

Issue 3859003: FBTF: Even more ctor/virtual deinlining. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 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) 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 // Some basic utilities for aiding in the management of Tasks and Callbacks. 5 // Some basic utilities for aiding in the management of Tasks and Callbacks.
6 // 6 //
7 // AutoTaskRunner, and its brother AutoCallbackRunner are the scoped_ptr 7 // AutoTaskRunner, and its brother AutoCallbackRunner are the scoped_ptr
8 // equivalents for callbacks. They are useful for ensuring a callback is 8 // equivalents for callbacks. They are useful for ensuring a callback is
9 // executed and delete in the face of multiple return points in a function. 9 // executed and delete in the face of multiple return points in a function.
10 // 10 //
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 DISALLOW_COPY_AND_ASSIGN(AutoTaskRunner); 44 DISALLOW_COPY_AND_ASSIGN(AutoTaskRunner);
45 }; 45 };
46 46
47 class AutoCallbackRunner { 47 class AutoCallbackRunner {
48 public: 48 public:
49 // Takes ownership of the callback. 49 // Takes ownership of the callback.
50 explicit AutoCallbackRunner(Callback0::Type* callback) 50 explicit AutoCallbackRunner(Callback0::Type* callback)
51 : callback_(callback) { 51 : callback_(callback) {
52 } 52 }
53 53
54 ~AutoCallbackRunner() { 54 ~AutoCallbackRunner();
55 if (callback_.get()) {
56 callback_->Run();
57 }
58 }
59 55
60 Callback0::Type* release() { return callback_.release(); } 56 Callback0::Type* release() { return callback_.release(); }
61 57
62 private: 58 private:
63 scoped_ptr<Callback0::Type> callback_; 59 scoped_ptr<Callback0::Type> callback_;
64 60
65 DISALLOW_COPY_AND_ASSIGN(AutoCallbackRunner); 61 DISALLOW_COPY_AND_ASSIGN(AutoCallbackRunner);
66 }; 62 };
67 63
68 class TaskToCallbackAdapter : public Callback0::Type { 64 class TaskToCallbackAdapter : public Callback0::Type {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 private: 105 private:
110 scoped_ptr<CallbackType> callback_; 106 scoped_ptr<CallbackType> callback_;
111 std::vector<Task*> run_when_done_; 107 std::vector<Task*> run_when_done_;
112 108
113 DISALLOW_COPY_AND_ASSIGN(CleanupCallback); 109 DISALLOW_COPY_AND_ASSIGN(CleanupCallback);
114 }; 110 };
115 111
116 } // namespace media 112 } // namespace media
117 113
118 #endif // MEDIA_BASE_CALLBACK_ 114 #endif // MEDIA_BASE_CALLBACK_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698