| OLD | NEW |
| 1 // This file was GENERATED by command: | 1 // This file was GENERATED by command: |
| 2 // pump.py callback.h.pump | 2 // pump.py callback.h.pump |
| 3 // DO NOT EDIT BY HAND!!! | 3 // DO NOT EDIT BY HAND!!! |
| 4 | 4 |
| 5 | 5 |
| 6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 6 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 7 // Use of this source code is governed by a BSD-style license that can be | 7 // Use of this source code is governed by a BSD-style license that can be |
| 8 // found in the LICENSE file. | 8 // found in the LICENSE file. |
| 9 | 9 |
| 10 #ifndef BASE_CALLBACK_H_ | 10 #ifndef BASE_CALLBACK_H_ |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 // We pass InvokerStorageHolder by const ref to avoid incurring an | 232 // We pass InvokerStorageHolder by const ref to avoid incurring an |
| 233 // unnecessary AddRef/Unref pair even though we will modify the object. | 233 // unnecessary AddRef/Unref pair even though we will modify the object. |
| 234 // We cannot use a normal reference because the compiler will warn | 234 // We cannot use a normal reference because the compiler will warn |
| 235 // since this is often used on a return value, which is a temporary. | 235 // since this is often used on a return value, which is a temporary. |
| 236 // | 236 // |
| 237 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 237 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
| 238 // return the exact Callback<> type. See base/bind.h for details. | 238 // return the exact Callback<> type. See base/bind.h for details. |
| 239 template <typename T> | 239 template <typename T> |
| 240 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 240 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
| 241 : polymorphic_invoke_(&T::FunctionTraits::DoInvoke) { | 241 : polymorphic_invoke_(&T::Invoker::DoInvoke) { |
| 242 invoker_storage_.swap(invoker_holder.invoker_storage_); | 242 invoker_storage_.swap(invoker_holder.invoker_storage_); |
| 243 } | 243 } |
| 244 | 244 |
| 245 R Run(void) const { | 245 R Run(void) const { |
| 246 return polymorphic_invoke_(invoker_storage_.get()); | 246 return polymorphic_invoke_(invoker_storage_.get()); |
| 247 } | 247 } |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 scoped_refptr<internal::InvokerStorageBase> invoker_storage_; | 250 scoped_refptr<internal::InvokerStorageBase> invoker_storage_; |
| 251 PolymorphicInvoke polymorphic_invoke_; | 251 PolymorphicInvoke polymorphic_invoke_; |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 template <typename R, typename A1> | 254 template <typename R, typename A1> |
| 255 class Callback<R(A1)> { | 255 class Callback<R(A1)> { |
| 256 public: | 256 public: |
| 257 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&); | 257 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&); |
| 258 | 258 |
| 259 Callback() : polymorphic_invoke_(NULL) { } | 259 Callback() : polymorphic_invoke_(NULL) { } |
| 260 | 260 |
| 261 // We pass InvokerStorageHolder by const ref to avoid incurring an | 261 // We pass InvokerStorageHolder by const ref to avoid incurring an |
| 262 // unnecessary AddRef/Unref pair even though we will modify the object. | 262 // unnecessary AddRef/Unref pair even though we will modify the object. |
| 263 // We cannot use a normal reference because the compiler will warn | 263 // We cannot use a normal reference because the compiler will warn |
| 264 // since this is often used on a return value, which is a temporary. | 264 // since this is often used on a return value, which is a temporary. |
| 265 // | 265 // |
| 266 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 266 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
| 267 // return the exact Callback<> type. See base/bind.h for details. | 267 // return the exact Callback<> type. See base/bind.h for details. |
| 268 template <typename T> | 268 template <typename T> |
| 269 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 269 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
| 270 : polymorphic_invoke_(&T::FunctionTraits::DoInvoke) { | 270 : polymorphic_invoke_(&T::Invoker::DoInvoke) { |
| 271 invoker_storage_.swap(invoker_holder.invoker_storage_); | 271 invoker_storage_.swap(invoker_holder.invoker_storage_); |
| 272 } | 272 } |
| 273 | 273 |
| 274 R Run(const A1& a1) const { | 274 R Run(const A1& a1) const { |
| 275 return polymorphic_invoke_(invoker_storage_.get(), a1); | 275 return polymorphic_invoke_(invoker_storage_.get(), a1); |
| 276 } | 276 } |
| 277 | 277 |
| 278 private: | 278 private: |
| 279 scoped_refptr<internal::InvokerStorageBase> invoker_storage_; | 279 scoped_refptr<internal::InvokerStorageBase> invoker_storage_; |
| 280 PolymorphicInvoke polymorphic_invoke_; | 280 PolymorphicInvoke polymorphic_invoke_; |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 template <typename R, typename A1, typename A2> | 283 template <typename R, typename A1, typename A2> |
| 284 class Callback<R(A1, A2)> { | 284 class Callback<R(A1, A2)> { |
| 285 public: | 285 public: |
| 286 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, | 286 typedef R(*PolymorphicInvoke)(internal::InvokerStorageBase*, const A1&, |
| 287 const A2&); | 287 const A2&); |
| 288 | 288 |
| 289 Callback() : polymorphic_invoke_(NULL) { } | 289 Callback() : polymorphic_invoke_(NULL) { } |
| 290 | 290 |
| 291 // We pass InvokerStorageHolder by const ref to avoid incurring an | 291 // We pass InvokerStorageHolder by const ref to avoid incurring an |
| 292 // unnecessary AddRef/Unref pair even though we will modify the object. | 292 // unnecessary AddRef/Unref pair even though we will modify the object. |
| 293 // We cannot use a normal reference because the compiler will warn | 293 // We cannot use a normal reference because the compiler will warn |
| 294 // since this is often used on a return value, which is a temporary. | 294 // since this is often used on a return value, which is a temporary. |
| 295 // | 295 // |
| 296 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 296 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
| 297 // return the exact Callback<> type. See base/bind.h for details. | 297 // return the exact Callback<> type. See base/bind.h for details. |
| 298 template <typename T> | 298 template <typename T> |
| 299 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 299 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
| 300 : polymorphic_invoke_(&T::FunctionTraits::DoInvoke) { | 300 : polymorphic_invoke_(&T::Invoker::DoInvoke) { |
| 301 invoker_storage_.swap(invoker_holder.invoker_storage_); | 301 invoker_storage_.swap(invoker_holder.invoker_storage_); |
| 302 } | 302 } |
| 303 | 303 |
| 304 R Run(const A1& a1, | 304 R Run(const A1& a1, |
| 305 const A2& a2) const { | 305 const A2& a2) const { |
| 306 return polymorphic_invoke_(invoker_storage_.get(), a1, | 306 return polymorphic_invoke_(invoker_storage_.get(), a1, |
| 307 a2); | 307 a2); |
| 308 } | 308 } |
| 309 | 309 |
| 310 private: | 310 private: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 323 | 323 |
| 324 // We pass InvokerStorageHolder by const ref to avoid incurring an | 324 // We pass InvokerStorageHolder by const ref to avoid incurring an |
| 325 // unnecessary AddRef/Unref pair even though we will modify the object. | 325 // unnecessary AddRef/Unref pair even though we will modify the object. |
| 326 // We cannot use a normal reference because the compiler will warn | 326 // We cannot use a normal reference because the compiler will warn |
| 327 // since this is often used on a return value, which is a temporary. | 327 // since this is often used on a return value, which is a temporary. |
| 328 // | 328 // |
| 329 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 329 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
| 330 // return the exact Callback<> type. See base/bind.h for details. | 330 // return the exact Callback<> type. See base/bind.h for details. |
| 331 template <typename T> | 331 template <typename T> |
| 332 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 332 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
| 333 : polymorphic_invoke_(&T::FunctionTraits::DoInvoke) { | 333 : polymorphic_invoke_(&T::Invoker::DoInvoke) { |
| 334 invoker_storage_.swap(invoker_holder.invoker_storage_); | 334 invoker_storage_.swap(invoker_holder.invoker_storage_); |
| 335 } | 335 } |
| 336 | 336 |
| 337 R Run(const A1& a1, | 337 R Run(const A1& a1, |
| 338 const A2& a2, | 338 const A2& a2, |
| 339 const A3& a3) const { | 339 const A3& a3) const { |
| 340 return polymorphic_invoke_(invoker_storage_.get(), a1, | 340 return polymorphic_invoke_(invoker_storage_.get(), a1, |
| 341 a2, | 341 a2, |
| 342 a3); | 342 a3); |
| 343 } | 343 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 359 | 359 |
| 360 // We pass InvokerStorageHolder by const ref to avoid incurring an | 360 // We pass InvokerStorageHolder by const ref to avoid incurring an |
| 361 // unnecessary AddRef/Unref pair even though we will modify the object. | 361 // unnecessary AddRef/Unref pair even though we will modify the object. |
| 362 // We cannot use a normal reference because the compiler will warn | 362 // We cannot use a normal reference because the compiler will warn |
| 363 // since this is often used on a return value, which is a temporary. | 363 // since this is often used on a return value, which is a temporary. |
| 364 // | 364 // |
| 365 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 365 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
| 366 // return the exact Callback<> type. See base/bind.h for details. | 366 // return the exact Callback<> type. See base/bind.h for details. |
| 367 template <typename T> | 367 template <typename T> |
| 368 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 368 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
| 369 : polymorphic_invoke_(&T::FunctionTraits::DoInvoke) { | 369 : polymorphic_invoke_(&T::Invoker::DoInvoke) { |
| 370 invoker_storage_.swap(invoker_holder.invoker_storage_); | 370 invoker_storage_.swap(invoker_holder.invoker_storage_); |
| 371 } | 371 } |
| 372 | 372 |
| 373 R Run(const A1& a1, | 373 R Run(const A1& a1, |
| 374 const A2& a2, | 374 const A2& a2, |
| 375 const A3& a3, | 375 const A3& a3, |
| 376 const A4& a4) const { | 376 const A4& a4) const { |
| 377 return polymorphic_invoke_(invoker_storage_.get(), a1, | 377 return polymorphic_invoke_(invoker_storage_.get(), a1, |
| 378 a2, | 378 a2, |
| 379 a3, | 379 a3, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 399 | 399 |
| 400 // We pass InvokerStorageHolder by const ref to avoid incurring an | 400 // We pass InvokerStorageHolder by const ref to avoid incurring an |
| 401 // unnecessary AddRef/Unref pair even though we will modify the object. | 401 // unnecessary AddRef/Unref pair even though we will modify the object. |
| 402 // We cannot use a normal reference because the compiler will warn | 402 // We cannot use a normal reference because the compiler will warn |
| 403 // since this is often used on a return value, which is a temporary. | 403 // since this is often used on a return value, which is a temporary. |
| 404 // | 404 // |
| 405 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 405 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
| 406 // return the exact Callback<> type. See base/bind.h for details. | 406 // return the exact Callback<> type. See base/bind.h for details. |
| 407 template <typename T> | 407 template <typename T> |
| 408 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 408 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
| 409 : polymorphic_invoke_(&T::FunctionTraits::DoInvoke) { | 409 : polymorphic_invoke_(&T::Invoker::DoInvoke) { |
| 410 invoker_storage_.swap(invoker_holder.invoker_storage_); | 410 invoker_storage_.swap(invoker_holder.invoker_storage_); |
| 411 } | 411 } |
| 412 | 412 |
| 413 R Run(const A1& a1, | 413 R Run(const A1& a1, |
| 414 const A2& a2, | 414 const A2& a2, |
| 415 const A3& a3, | 415 const A3& a3, |
| 416 const A4& a4, | 416 const A4& a4, |
| 417 const A5& a5) const { | 417 const A5& a5) const { |
| 418 return polymorphic_invoke_(invoker_storage_.get(), a1, | 418 return polymorphic_invoke_(invoker_storage_.get(), a1, |
| 419 a2, | 419 a2, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 442 | 442 |
| 443 // We pass InvokerStorageHolder by const ref to avoid incurring an | 443 // We pass InvokerStorageHolder by const ref to avoid incurring an |
| 444 // unnecessary AddRef/Unref pair even though we will modify the object. | 444 // unnecessary AddRef/Unref pair even though we will modify the object. |
| 445 // We cannot use a normal reference because the compiler will warn | 445 // We cannot use a normal reference because the compiler will warn |
| 446 // since this is often used on a return value, which is a temporary. | 446 // since this is often used on a return value, which is a temporary. |
| 447 // | 447 // |
| 448 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 448 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
| 449 // return the exact Callback<> type. See base/bind.h for details. | 449 // return the exact Callback<> type. See base/bind.h for details. |
| 450 template <typename T> | 450 template <typename T> |
| 451 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) | 451 Callback(const internal::InvokerStorageHolder<T>& invoker_holder) |
| 452 : polymorphic_invoke_(&T::FunctionTraits::DoInvoke) { | 452 : polymorphic_invoke_(&T::Invoker::DoInvoke) { |
| 453 invoker_storage_.swap(invoker_holder.invoker_storage_); | 453 invoker_storage_.swap(invoker_holder.invoker_storage_); |
| 454 } | 454 } |
| 455 | 455 |
| 456 R Run(const A1& a1, | 456 R Run(const A1& a1, |
| 457 const A2& a2, | 457 const A2& a2, |
| 458 const A3& a3, | 458 const A3& a3, |
| 459 const A4& a4, | 459 const A4& a4, |
| 460 const A5& a5, | 460 const A5& a5, |
| 461 const A6& a6) const { | 461 const A6& a6) const { |
| 462 return polymorphic_invoke_(invoker_storage_.get(), a1, | 462 return polymorphic_invoke_(invoker_storage_.get(), a1, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 473 }; | 473 }; |
| 474 | 474 |
| 475 | 475 |
| 476 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it | 476 // Syntactic sugar to make Callbacks<void(void)> easier to declare since it |
| 477 // will be used in a lot of APIs with delayed execution. | 477 // will be used in a lot of APIs with delayed execution. |
| 478 typedef Callback<void(void)> Closure; | 478 typedef Callback<void(void)> Closure; |
| 479 | 479 |
| 480 } // namespace base | 480 } // namespace base |
| 481 | 481 |
| 482 #endif // BASE_CALLBACK_H | 482 #endif // BASE_CALLBACK_H |
| OLD | NEW |