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

Side by Side Diff: chrome/browser/chromeos/camera_detector.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/chromeos/camera_detector.h" 5 #include "chrome/browser/chromeos/camera_detector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_enumerator.h"
9 #include "base/location.h" 10 #include "base/location.h"
10 #include "base/string_util.h" 11 #include "base/string_util.h"
11 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
12 #include "base/task_runner_util.h" 13 #include "base/task_runner_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
14 #include "chrome/browser/storage_monitor/udev_util_linux.h" 15 #include "chrome/browser/storage_monitor/udev_util_linux.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 17
17 namespace chromeos { 18 namespace chromeos {
18 19
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 DCHECK(BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 60 DCHECK(BrowserThread::CurrentlyOn(content::BrowserThread::UI));
60 camera_presence_ = present ? kCameraPresent : kCameraAbsent; 61 camera_presence_ = present ? kCameraPresent : kCameraAbsent;
61 presence_check_in_progress_ = false; 62 presence_check_in_progress_ = false;
62 callback.Run(); 63 callback.Run();
63 } 64 }
64 65
65 // static 66 // static
66 bool CameraDetector::CheckPresence() { 67 bool CameraDetector::CheckPresence() {
67 // We do a quick check using udev database because opening each /dev/videoX 68 // We do a quick check using udev database because opening each /dev/videoX
68 // device may trigger costly device initialization. 69 // device may trigger costly device initialization.
69 using file_util::FileEnumerator; 70 base::FileEnumerator file_enum(
70 FileEnumerator file_enum(
71 base::FilePath(kV4LSubsystemDir), false /* not recursive */, 71 base::FilePath(kV4LSubsystemDir), false /* not recursive */,
72 FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS); 72 base::FileEnumerator::FILES | base::FileEnumerator::SHOW_SYM_LINKS);
73 for (base::FilePath path = file_enum.Next(); !path.empty(); 73 for (base::FilePath path = file_enum.Next(); !path.empty();
74 path = file_enum.Next()) { 74 path = file_enum.Next()) {
75 std::string v4l_capabilities; 75 std::string v4l_capabilities;
76 if (chrome::GetUdevDevicePropertyValueByPath( 76 if (chrome::GetUdevDevicePropertyValueByPath(
77 path, kV4LCapabilities, &v4l_capabilities)) { 77 path, kV4LCapabilities, &v4l_capabilities)) {
78 std::vector<std::string> caps; 78 std::vector<std::string> caps;
79 base::SplitString(v4l_capabilities, kV4LCapabilitiesDelim, &caps); 79 base::SplitString(v4l_capabilities, kV4LCapabilitiesDelim, &caps);
80 if (find(caps.begin(), caps.end(), kV4LCaptureCapability) != caps.end()) { 80 if (find(caps.begin(), caps.end(), kV4LCaptureCapability) != caps.end()) {
81 return true; 81 return true;
82 } 82 }
83 } 83 }
84 } 84 }
85 return false; 85 return false;
86 } 86 }
87 87
88 } // namespace chromeos 88 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698