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

Side by Side Diff: extensions/browser/api/webcam_private/webcam_private_api.h

Issue 1136883004: Move V4L2 code into a webcam helper class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix move detection Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
6 #define EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_ 6 #define EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
7 7
8 #include <map>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/scoped_observer.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
8 #include "extensions/browser/extension_function.h" 13 #include "extensions/browser/extension_function.h"
14 #include "extensions/browser/process_manager_observer.h"
9 15
10 class Profile; 16 class Profile;
11 17
12 namespace extensions { 18 namespace extensions {
13 19
20 class ProcessManager;
21 class Webcam;
22
23 class WebcamPrivateAPI : public BrowserContextKeyedAPI,
24 public ProcessManagerObserver {
25 public:
26 // Convenience method to get the WebcamPrivateAPI for a BrowserContext.
27 static WebcamPrivateAPI* Get(content::BrowserContext* context);
28
29 explicit WebcamPrivateAPI(content::BrowserContext* context);
30 ~WebcamPrivateAPI() override;
31
32 Webcam* GetWebcam(const std::string& extension_id,
33 const std::string& webcam_id);
34
35 private:
36 friend class BrowserContextKeyedAPIFactory<WebcamPrivateAPI>;
37
38 bool GetDeviceId(const std::string& extension_id,
39 const std::string& webcam_id,
40 std::string* device_id);
41
42 // ProcessManagerObserver:
43 void OnBackgroundHostClose(const std::string& extension_id) override;
44
45 // BrowserContextKeyedAPI:
46 static BrowserContextKeyedAPIFactory<WebcamPrivateAPI>* GetFactoryInstance();
47 static const char* service_name() {
48 return "WebcamPrivateAPI";
49 }
50 static const bool kServiceIsNULLWhileTesting = true;
51 static const bool kServiceRedirectedInIncognito = true;
52
53 content::BrowserContext* const browser_context_;
54 ScopedObserver<ProcessManager, ProcessManagerObserver>
55 process_manager_observer_;
56
57 std::map<std::string, linked_ptr<Webcam>> webcams_;
58
59 base::WeakPtrFactory<WebcamPrivateAPI> weak_ptr_factory_;
60 };
61
14 class WebcamPrivateSetFunction : public SyncExtensionFunction { 62 class WebcamPrivateSetFunction : public SyncExtensionFunction {
15 public: 63 public:
16 WebcamPrivateSetFunction(); 64 WebcamPrivateSetFunction();
17 DECLARE_EXTENSION_FUNCTION("webcamPrivate.set", WEBCAMPRIVATE_SET); 65 DECLARE_EXTENSION_FUNCTION("webcamPrivate.set", WEBCAMPRIVATE_SET);
18 66
19 protected: 67 protected:
20 ~WebcamPrivateSetFunction() override; 68 ~WebcamPrivateSetFunction() override;
21 bool RunSync() override; 69 bool RunSync() override;
22 70
23 private: 71 private:
(...skipping 22 matching lines...) Expand all
46 ~WebcamPrivateResetFunction() override; 94 ~WebcamPrivateResetFunction() override;
47 bool RunSync() override; 95 bool RunSync() override;
48 96
49 private: 97 private:
50 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateResetFunction); 98 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateResetFunction);
51 }; 99 };
52 100
53 } // namespace extensions 101 } // namespace extensions
54 102
55 #endif // EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_ 103 #endif // EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698