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

Side by Side Diff: base/task.h

Issue 3549010: Fix raw_scoped_refptr_mismatch_checker.h. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Disable on Windows Created 10 years 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
« no previous file with comments | « base/raw_scoped_refptr_mismatch_checker.h ('k') | base/template_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef BASE_TASK_H_ 5 #ifndef BASE_TASK_H_
6 #define BASE_TASK_H_ 6 #define BASE_TASK_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/non_thread_safe.h" 9 #include "base/non_thread_safe.h"
10 #include "base/raw_scoped_refptr_mismatch_checker.h" 10 #include "base/raw_scoped_refptr_mismatch_checker.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 protected: 142 protected:
143 template <class Method, class Params> 143 template <class Method, class Params>
144 class RunnableMethod : public CancelableTask { 144 class RunnableMethod : public CancelableTask {
145 public: 145 public:
146 RunnableMethod(const base::WeakPtr<T>& obj, 146 RunnableMethod(const base::WeakPtr<T>& obj,
147 Method meth, 147 Method meth,
148 const Params& params) 148 const Params& params)
149 : obj_(obj), 149 : obj_(obj),
150 meth_(meth), 150 meth_(meth),
151 params_(params) { 151 params_(params) {
152 COMPILE_ASSERT((MethodUsesScopedRefptrCorrectly<Method, Params>::value), 152 COMPILE_ASSERT(
153 badscopedrunnablemethodparams); 153 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value),
154 badscopedrunnablemethodparams);
154 } 155 }
155 156
156 virtual void Run() { 157 virtual void Run() {
157 if (obj_) 158 if (obj_)
158 DispatchToMethod(obj_.get(), meth_, params_); 159 DispatchToMethod(obj_.get(), meth_, params_);
159 } 160 }
160 161
161 virtual void Cancel() { 162 virtual void Cancel() {
162 obj_.reset(); 163 obj_.reset();
163 } 164 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // PostTask(FROM_HERE, NewRunnableFunction(&function[, a[, b]]) 311 // PostTask(FROM_HERE, NewRunnableFunction(&function[, a[, b]])
311 312
312 // RunnableMethod and NewRunnableMethod implementation ------------------------- 313 // RunnableMethod and NewRunnableMethod implementation -------------------------
313 314
314 template <class T, class Method, class Params> 315 template <class T, class Method, class Params>
315 class RunnableMethod : public CancelableTask { 316 class RunnableMethod : public CancelableTask {
316 public: 317 public:
317 RunnableMethod(T* obj, Method meth, const Params& params) 318 RunnableMethod(T* obj, Method meth, const Params& params)
318 : obj_(obj), meth_(meth), params_(params) { 319 : obj_(obj), meth_(meth), params_(params) {
319 traits_.RetainCallee(obj_); 320 traits_.RetainCallee(obj_);
320 COMPILE_ASSERT((MethodUsesScopedRefptrCorrectly<Method, Params>::value), 321 COMPILE_ASSERT(
321 badrunnablemethodparams); 322 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value),
323 badrunnablemethodparams);
322 } 324 }
323 325
324 ~RunnableMethod() { 326 ~RunnableMethod() {
325 ReleaseCallee(); 327 ReleaseCallee();
326 } 328 }
327 329
328 virtual void Run() { 330 virtual void Run() {
329 if (obj_) 331 if (obj_)
330 DispatchToMethod(obj_, meth_, params_); 332 DispatchToMethod(obj_, meth_, params_);
331 } 333 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 e, f, g)); 424 e, f, g));
423 } 425 }
424 426
425 // RunnableFunction and NewRunnableFunction implementation --------------------- 427 // RunnableFunction and NewRunnableFunction implementation ---------------------
426 428
427 template <class Function, class Params> 429 template <class Function, class Params>
428 class RunnableFunction : public CancelableTask { 430 class RunnableFunction : public CancelableTask {
429 public: 431 public:
430 RunnableFunction(Function function, const Params& params) 432 RunnableFunction(Function function, const Params& params)
431 : function_(function), params_(params) { 433 : function_(function), params_(params) {
432 COMPILE_ASSERT((FunctionUsesScopedRefptrCorrectly<Function, Params>::value), 434 COMPILE_ASSERT(
433 badrunnablefunctionparams); 435 (base::internal::ParamsUseScopedRefptrCorrectly<Params>::value),
436 badrunnablefunctionparams);
434 } 437 }
435 438
436 ~RunnableFunction() { 439 ~RunnableFunction() {
437 } 440 }
438 441
439 virtual void Run() { 442 virtual void Run() {
440 if (function_) 443 if (function_)
441 DispatchToFunction(function_, params_); 444 DispatchToFunction(function_, params_);
442 } 445 }
443 446
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 inline CancelableTask* NewRunnableFunction(Function function, 523 inline CancelableTask* NewRunnableFunction(Function function,
521 const A& a, const B& b, 524 const A& a, const B& b,
522 const C& c, const D& d, 525 const C& c, const D& d,
523 const E& e, const F& f, 526 const E& e, const F& f,
524 const G& g, const H& h) { 527 const G& g, const H& h) {
525 return new RunnableFunction<Function, Tuple8<A, B, C, D, E, F, G, H> >( 528 return new RunnableFunction<Function, Tuple8<A, B, C, D, E, F, G, H> >(
526 function, MakeTuple(a, b, c, d, e, f, g, h)); 529 function, MakeTuple(a, b, c, d, e, f, g, h));
527 } 530 }
528 531
529 #endif // BASE_TASK_H_ 532 #endif // BASE_TASK_H_
OLDNEW
« no previous file with comments | « base/raw_scoped_refptr_mismatch_checker.h ('k') | base/template_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698