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: chrome/browser/extensions/api/copresence/copresence_api.h

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 class CopresenceManager; 21 class CopresenceManager;
22 class WhispernetClient; 22 class WhispernetClient;
23 } 23 }
24 24
25 namespace extensions { 25 namespace extensions {
26 26
27 class CopresenceService : public BrowserContextKeyedAPI, 27 class CopresenceService : public BrowserContextKeyedAPI,
28 public copresence::CopresenceDelegate { 28 public copresence::CopresenceDelegate {
29 public: 29 public:
30 explicit CopresenceService(content::BrowserContext* context); 30 explicit CopresenceService(content::BrowserContext* context);
31 virtual ~CopresenceService(); 31 ~CopresenceService() override;
32 32
33 // BrowserContextKeyedAPI implementation. 33 // BrowserContextKeyedAPI implementation.
34 virtual void Shutdown() override; 34 void Shutdown() override;
35 35
36 // These accessors will always return an object (except during shutdown). 36 // These accessors will always return an object (except during shutdown).
37 // If the object doesn't exist, they will create one first. 37 // If the object doesn't exist, they will create one first.
38 copresence::CopresenceManager* manager(); 38 copresence::CopresenceManager* manager();
39 copresence::WhispernetClient* whispernet_client(); 39 copresence::WhispernetClient* whispernet_client();
40 40
41 // A registry containing the app id's associated with every subscription. 41 // A registry containing the app id's associated with every subscription.
42 SubscriptionToAppMap& apps_by_subscription_id() { 42 SubscriptionToAppMap& apps_by_subscription_id() {
43 return apps_by_subscription_id_; 43 return apps_by_subscription_id_;
44 } 44 }
45 45
46 void set_api_key(const std::string& api_key) { api_key_ = api_key; } 46 void set_api_key(const std::string& api_key) { api_key_ = api_key; }
47 47
48 // Manager override for testing. 48 // Manager override for testing.
49 void set_manager_for_testing( 49 void set_manager_for_testing(
50 scoped_ptr<copresence::CopresenceManager> manager); 50 scoped_ptr<copresence::CopresenceManager> manager);
51 51
52 // BrowserContextKeyedAPI implementation. 52 // BrowserContextKeyedAPI implementation.
53 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance(); 53 static BrowserContextKeyedAPIFactory<CopresenceService>* GetFactoryInstance();
54 54
55 private: 55 private:
56 friend class BrowserContextKeyedAPIFactory<CopresenceService>; 56 friend class BrowserContextKeyedAPIFactory<CopresenceService>;
57 57
58 // CopresenceDelegate implementation 58 // CopresenceDelegate implementation
59 virtual void HandleMessages( 59 void HandleMessages(const std::string& app_id,
60 const std::string& app_id, 60 const std::string& subscription_id,
61 const std::string& subscription_id, 61 const std::vector<copresence::Message>& message) override;
62 const std::vector<copresence::Message>& message) override; 62 net::URLRequestContextGetter* GetRequestContext() const override;
63 virtual net::URLRequestContextGetter* GetRequestContext() const override; 63 const std::string GetPlatformVersionString() const override;
64 virtual const std::string GetPlatformVersionString() const override; 64 const std::string GetAPIKey() const override;
65 virtual const std::string GetAPIKey() const override; 65 copresence::WhispernetClient* GetWhispernetClient() override;
66 virtual copresence::WhispernetClient* GetWhispernetClient() override;
67 66
68 // BrowserContextKeyedAPI implementation. 67 // BrowserContextKeyedAPI implementation.
69 static const char* service_name() { return "CopresenceService"; } 68 static const char* service_name() { return "CopresenceService"; }
70 69
71 bool is_shutting_down_; 70 bool is_shutting_down_;
72 std::map<std::string, std::string> apps_by_subscription_id_; 71 std::map<std::string, std::string> apps_by_subscription_id_;
73 72
74 content::BrowserContext* const browser_context_; 73 content::BrowserContext* const browser_context_;
75 std::string api_key_; 74 std::string api_key_;
76 75
77 scoped_ptr<copresence::CopresenceManager> manager_; 76 scoped_ptr<copresence::CopresenceManager> manager_;
78 scoped_ptr<copresence::WhispernetClient> whispernet_client_; 77 scoped_ptr<copresence::WhispernetClient> whispernet_client_;
79 78
80 DISALLOW_COPY_AND_ASSIGN(CopresenceService); 79 DISALLOW_COPY_AND_ASSIGN(CopresenceService);
81 }; 80 };
82 81
83 template <> 82 template <>
84 void BrowserContextKeyedAPIFactory< 83 void BrowserContextKeyedAPIFactory<
85 CopresenceService>::DeclareFactoryDependencies(); 84 CopresenceService>::DeclareFactoryDependencies();
86 85
87 class CopresenceExecuteFunction : public ChromeUIThreadExtensionFunction { 86 class CopresenceExecuteFunction : public ChromeUIThreadExtensionFunction {
88 public: 87 public:
89 DECLARE_EXTENSION_FUNCTION("copresence.execute", COPRESENCE_EXECUTE); 88 DECLARE_EXTENSION_FUNCTION("copresence.execute", COPRESENCE_EXECUTE);
90 89
91 protected: 90 protected:
92 virtual ~CopresenceExecuteFunction() {} 91 ~CopresenceExecuteFunction() override {}
93 virtual ExtensionFunction::ResponseAction Run() override; 92 ExtensionFunction::ResponseAction Run() override;
94 93
95 private: 94 private:
96 void SendResult(copresence::CopresenceStatus status); 95 void SendResult(copresence::CopresenceStatus status);
97 }; 96 };
98 97
99 class CopresenceSetApiKeyFunction : public ChromeUIThreadExtensionFunction { 98 class CopresenceSetApiKeyFunction : public ChromeUIThreadExtensionFunction {
100 public: 99 public:
101 DECLARE_EXTENSION_FUNCTION("copresence.setApiKey", COPRESENCE_SETAPIKEY); 100 DECLARE_EXTENSION_FUNCTION("copresence.setApiKey", COPRESENCE_SETAPIKEY);
102 101
103 protected: 102 protected:
104 virtual ~CopresenceSetApiKeyFunction() {} 103 ~CopresenceSetApiKeyFunction() override {}
105 virtual ExtensionFunction::ResponseAction Run() override; 104 ExtensionFunction::ResponseAction Run() override;
106 }; 105 };
107 106
108 } // namespace extensions 107 } // namespace extensions
109 108
110 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_ 109 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698