Allow SequencedTaskRunner argument in InterfacePtr::Bind().

Discussion at:
https://groups.google.com/a/chromium.org/d/msg/chromium-mojo/PxJTGC-xZmQ/Jx04J27RAwAJ

Today, InterfacePtr::Bind() accepts a SingleThreadTaskRunner argument to use to
dispatch callbacks and error notifications. This is useful to bind an interface
to a specific task queue of the Blink scheduler. If someone wants to bind an
interface to a SequencedTaskRunner which isn't a SingleThreadTaskRunner, they
have to leave the argument nullptr and rely on the default behavior of using
SequencedTaskRunnerHandle::Get().

This is inconvenient for classes that support running on a SequencedTaskRunner
*or* a SingleThreadTaskRunner and want to bind an interface. Simplified example:

class Foo {
 public:
  // Foo sometimes runs on a Blink scheduler task queue, in which case a
  // SingleThreadTaskRunner will be passed as argument. But it can also
  // run on a TaskScheduler SequencedTaskRunner.
  Foo(scoped_refptr<SequencedTaskRunner> task_runner)
    : task_runner_(std::move(task_runner)) {}

  void DoSomething() {
    task_runner_->PostTask(FROM_HERE, ...);
  }

  void BindSomething() {
    // Impossible! Because |task_runner_| is not a SingleThreadTaskRunner.
    // Foo shouldn't have to know whether it is running on a
    // SingleThreadTaskRunner or a SequencedTaskRunner.
    interface_.Bind(..., task_runner_);
  }

 private:
  MyInterfacePtr interface_;
  scoped_refptr<SequencedTaskRunner> task_runner_;
}

This CL fixes the issue by changing the argument type of InterfacePtr::Bind()
and AssociatedInterfacePtr::Bind() to SequencedTaskRunner.

Bug: 844039
Change-Id: Ie0febeccaf002299e5a771d3ac885fb9cd18db8b
Reviewed-on: https://chromium-review.googlesource.com/1064311
Reviewed-by: Ken Rockot <rockot@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559581}

CrOS-Libchrome-Original-Commit: 6ac0dc16d307483b88be911c791d3fccfb8516f4
8 files changed
tree: eed6847121433eb1dc3ede346e12e0a3cb38394c
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/