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

Side by Side Diff: chrome/browser/extensions/api/audio_modem/audio_modem_api.h

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CHROME_BROWSER_EXTENSIONS_API_AUDIO_MODEM_AUDIO_MODEM_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUDIO_MODEM_AUDIO_MODEM_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_AUDIO_MODEM_AUDIO_MODEM_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_AUDIO_MODEM_AUDIO_MODEM_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/common/extensions/api/audio_modem.h" 14 #include "chrome/common/extensions/api/audio_modem.h"
15 #include "components/audio_modem/public/modem.h" 15 #include "components/audio_modem/public/modem.h"
16 #include "extensions/browser/browser_context_keyed_api_factory.h" 16 #include "extensions/browser/browser_context_keyed_api_factory.h"
17 #include "extensions/browser/extension_function.h" 17 #include "extensions/browser/extension_function.h"
18 #include "extensions/browser/extension_function_histogram_value.h" 18 #include "extensions/browser/extension_function_histogram_value.h"
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 // Implementation of the chrome.audioModem API. 22 // Implementation of the chrome.audioModem API.
23 class AudioModemAPI final : public BrowserContextKeyedAPI { 23 class AudioModemAPI final : public BrowserContextKeyedAPI {
24 public: 24 public:
25 // Default constructor. 25 // Default constructor.
26 explicit AudioModemAPI(content::BrowserContext* context); 26 explicit AudioModemAPI(content::BrowserContext* context);
27 27
28 // Testing constructor: pass in dependencies. 28 // Testing constructor: pass in dependencies.
29 AudioModemAPI(content::BrowserContext* context, 29 AudioModemAPI(
30 scoped_ptr<audio_modem::WhispernetClient> whispernet_client, 30 content::BrowserContext* context,
31 scoped_ptr<audio_modem::Modem> modem); 31 std::unique_ptr<audio_modem::WhispernetClient> whispernet_client,
32 std::unique_ptr<audio_modem::Modem> modem);
32 33
33 ~AudioModemAPI() override; 34 ~AudioModemAPI() override;
34 35
35 // Starts transmitting a token, and returns the associated API status. 36 // Starts transmitting a token, and returns the associated API status.
36 // Fails if another app is already transmitting the same AudioType. 37 // Fails if another app is already transmitting the same AudioType.
37 api::audio_modem::Status StartTransmit( 38 api::audio_modem::Status StartTransmit(
38 const std::string& app_id, 39 const std::string& app_id,
39 const api::audio_modem::RequestParams& params, 40 const api::audio_modem::RequestParams& params,
40 const std::string& token); 41 const std::string& token);
41 42
(...skipping 17 matching lines...) Expand all
59 // BrowserContextKeyedAPI implementation. 60 // BrowserContextKeyedAPI implementation.
60 static BrowserContextKeyedAPIFactory<AudioModemAPI>* GetFactoryInstance(); 61 static BrowserContextKeyedAPIFactory<AudioModemAPI>* GetFactoryInstance();
61 62
62 private: 63 private:
63 friend class BrowserContextKeyedAPIFactory<AudioModemAPI>; 64 friend class BrowserContextKeyedAPIFactory<AudioModemAPI>;
64 65
65 void WhispernetInitComplete(bool success); 66 void WhispernetInitComplete(bool success);
66 void TokensReceived(const std::vector<audio_modem::AudioToken>& tokens); 67 void TokensReceived(const std::vector<audio_modem::AudioToken>& tokens);
67 68
68 content::BrowserContext* const browser_context_; 69 content::BrowserContext* const browser_context_;
69 scoped_ptr<audio_modem::WhispernetClient> whispernet_client_; 70 std::unique_ptr<audio_modem::WhispernetClient> whispernet_client_;
70 scoped_ptr<audio_modem::Modem> modem_; 71 std::unique_ptr<audio_modem::Modem> modem_;
71 bool init_failed_; 72 bool init_failed_;
72 73
73 // IDs for the currently transmitting app (if any), indexed by AudioType. 74 // IDs for the currently transmitting app (if any), indexed by AudioType.
74 std::string transmitters_[2]; 75 std::string transmitters_[2];
75 76
76 // Timeouts for the currently active transmits, indexed by AudioType. 77 // Timeouts for the currently active transmits, indexed by AudioType.
77 base::OneShotTimer transmit_timers_[2]; 78 base::OneShotTimer transmit_timers_[2];
78 79
79 // Maps of currently receiving app ID => timeouts. Indexed by AudioType. 80 // Maps of currently receiving app ID => timeouts. Indexed by AudioType.
80 // We own all of these pointers. Do not remove them without calling delete. 81 // We own all of these pointers. Do not remove them without calling delete.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 DECLARE_EXTENSION_FUNCTION("audioModem.stopReceive", AUDIOMODEM_STOPRECEIVE); 124 DECLARE_EXTENSION_FUNCTION("audioModem.stopReceive", AUDIOMODEM_STOPRECEIVE);
124 125
125 protected: 126 protected:
126 ~AudioModemStopReceiveFunction() override {} 127 ~AudioModemStopReceiveFunction() override {}
127 ExtensionFunction::ResponseAction Run() override; 128 ExtensionFunction::ResponseAction Run() override;
128 }; 129 };
129 130
130 } // namespace extensions 131 } // namespace extensions
131 132
132 #endif // CHROME_BROWSER_EXTENSIONS_API_AUDIO_MODEM_AUDIO_MODEM_API_H_ 133 #endif // CHROME_BROWSER_EXTENSIONS_API_AUDIO_MODEM_AUDIO_MODEM_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698