security/sandbox/chromium/base/thread_task_runner_handle.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/chromium/base/thread_task_runner_handle.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef BASE_THREAD_TASK_RUNNER_HANDLE_H_
     1.9 +#define BASE_THREAD_TASK_RUNNER_HANDLE_H_
    1.10 +
    1.11 +#include "base/base_export.h"
    1.12 +#include "base/memory/ref_counted.h"
    1.13 +
    1.14 +namespace base {
    1.15 +
    1.16 +class SingleThreadTaskRunner;
    1.17 +
    1.18 +// ThreadTaskRunnerHandle stores a reference to a thread's TaskRunner
    1.19 +// in thread-local storage.  Callers can then retrieve the TaskRunner
    1.20 +// for the current thread by calling ThreadTaskRunnerHandle::Get().
    1.21 +// At most one TaskRunner may be bound to each thread at a time.
    1.22 +class BASE_EXPORT ThreadTaskRunnerHandle {
    1.23 + public:
    1.24 +  // Gets the SingleThreadTaskRunner for the current thread.
    1.25 +  static scoped_refptr<SingleThreadTaskRunner> Get();
    1.26 +
    1.27 +  // Returns true if the SingleThreadTaskRunner is already created for
    1.28 +  // the current thread.
    1.29 +  static bool IsSet();
    1.30 +
    1.31 +  // Binds |task_runner| to the current thread. |task_runner| must belong
    1.32 +  // to the current thread for this to succeed.
    1.33 +  explicit ThreadTaskRunnerHandle(
    1.34 +      const scoped_refptr<SingleThreadTaskRunner>& task_runner);
    1.35 +  ~ThreadTaskRunnerHandle();
    1.36 +
    1.37 + private:
    1.38 +  scoped_refptr<SingleThreadTaskRunner> task_runner_;
    1.39 +};
    1.40 +
    1.41 +}  // namespace base
    1.42 +
    1.43 +#endif  // BASE_THREAD_TASK_RUNNER_HANDLE_H_

mercurial