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

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: rebase 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 static BrowserContextKeyedAPIFactory<WebcamPrivateAPI>* GetFactoryInstance();
27
28 // Convenience method to get the WebcamPrivateAPI for a BrowserContext.
29 static WebcamPrivateAPI* Get(content::BrowserContext* context);
30
31 explicit WebcamPrivateAPI(content::BrowserContext* context);
32 ~WebcamPrivateAPI() override;
33
34 Webcam* GetWebcam(const std::string& extension_id,
35 const std::string& webcam_id);
36
37 private:
38 friend class BrowserContextKeyedAPIFactory<WebcamPrivateAPI>;
39
40 bool GetDeviceId(const std::string& extension_id,
41 const std::string& webcam_id,
42 std::string* device_id);
43
44 // ProcessManagerObserver:
45 void OnBackgroundHostClose(const std::string& extension_id) override;
46
47 // BrowserContextKeyedAPI:
48 static const char* service_name() {
49 return "WebcamPrivateAPI";
50 }
51 static const bool kServiceIsNULLWhileTesting = true;
52 static const bool kServiceRedirectedInIncognito = true;
53
54 content::BrowserContext* const browser_context_;
55 ScopedObserver<ProcessManager, ProcessManagerObserver>
56 process_manager_observer_;
57
58 std::map<std::string, linked_ptr<Webcam>> webcams_;
59
60 base::WeakPtrFactory<WebcamPrivateAPI> weak_ptr_factory_;
61 };
62
63 template <>
64 void BrowserContextKeyedAPIFactory<WebcamPrivateAPI>
65 ::DeclareFactoryDependencies();
66
14 class WebcamPrivateSetFunction : public SyncExtensionFunction { 67 class WebcamPrivateSetFunction : public SyncExtensionFunction {
15 public: 68 public:
16 WebcamPrivateSetFunction(); 69 WebcamPrivateSetFunction();
17 DECLARE_EXTENSION_FUNCTION("webcamPrivate.set", WEBCAMPRIVATE_SET); 70 DECLARE_EXTENSION_FUNCTION("webcamPrivate.set", WEBCAMPRIVATE_SET);
18 71
19 protected: 72 protected:
20 ~WebcamPrivateSetFunction() override; 73 ~WebcamPrivateSetFunction() override;
21 bool RunSync() override; 74 bool RunSync() override;
22 75
23 private: 76 private:
(...skipping 22 matching lines...) Expand all
46 ~WebcamPrivateResetFunction() override; 99 ~WebcamPrivateResetFunction() override;
47 bool RunSync() override; 100 bool RunSync() override;
48 101
49 private: 102 private:
50 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateResetFunction); 103 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateResetFunction);
51 }; 104 };
52 105
53 } // namespace extensions 106 } // namespace extensions
54 107
55 #endif // EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_ 108 #endif // EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/webcam_private/webcam.cc ('k') | extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698