summaryrefslogtreecommitdiffstats
path: root/media/audio/cross_process_notification.cc
blob: 1806f777da31cea4a9bf737549382f7a89cc8426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/audio/cross_process_notification.h"

#include "base/logging.h"
#include "base/memory/scoped_ptr.h"

CrossProcessNotification::CrossProcessNotification() {}

CrossProcessNotification::WaitForMultiple::WaitForMultiple(
    const Notifications* notifications) {
  Reset(notifications);
}

int CrossProcessNotification::WaitForMultiple::Wait() {
  DCHECK(CalledOnValidThread());
  int ret = WaitMultiple(*notifications_, wait_offset_);
  wait_offset_ = (ret + 1) % notifications_->size();
  return ret;
}

void CrossProcessNotification::WaitForMultiple::Reset(
    const Notifications* notifications) {
  DCHECK(CalledOnValidThread());
  wait_offset_ = 0;
  notifications_ = notifications;
  DCHECK(!notifications_->empty());
}