Don't announce clipboard events if the event target is not visible and focused.
[chromium-blink-merge.git] / dbus / file_descriptor.cc
blobd2d6a31f1e3cdc091a2497d04aa6da62c79f3633
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/files/file.h"
6 #include "base/logging.h"
7 #include "dbus/file_descriptor.h"
9 namespace dbus {
11 FileDescriptor::~FileDescriptor() {
12 if (owner_)
13 base::File auto_closer(value_);
16 int FileDescriptor::value() const {
17 CHECK(valid_);
18 return value_;
21 int FileDescriptor::TakeValue() {
22 CHECK(valid_); // NB: check first so owner_ is unchanged if this triggers
23 owner_ = false;
24 return value_;
27 void FileDescriptor::CheckValidity() {
28 base::File file(value_);
29 base::File::Info info;
30 bool ok = file.GetInfo(&info);
31 file.TakePlatformFile(); // Prevent |value_| from being closed by |file|.
32 valid_ = (ok && !info.is_directory);
35 } // namespace dbus