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

Side by Side Diff: chrome/browser/extensions/extension_function.h

Issue 377036: Fix memory leak in AsyncExtensionFunction. (Closed)
Patch Set: feedback Created 11 years, 1 month 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_EXTENSION_FUNCTION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // Derived classes should implement this method to do their work and return 118 // Derived classes should implement this method to do their work and return
119 // success/failure. 119 // success/failure.
120 virtual bool RunImpl() = 0; 120 virtual bool RunImpl() = 0;
121 121
122 protected: 122 protected:
123 virtual ~AsyncExtensionFunction() {} 123 virtual ~AsyncExtensionFunction() {}
124 124
125 void SendResponse(bool success); 125 void SendResponse(bool success);
126 126
127 const ListValue* args_as_list() {
128 return static_cast<ListValue*>(args_.get());
129 }
130 const DictionaryValue* args_as_dictionary() {
131 return static_cast<DictionaryValue*>(args_.get());
132 }
133
127 // Note: After Run() returns, dispatcher() can be NULL. Since these getters 134 // Note: After Run() returns, dispatcher() can be NULL. Since these getters
128 // rely on dispatcher(), make sure it is valid before using them. 135 // rely on dispatcher(), make sure it is valid before using them.
129 std::string extension_id(); 136 std::string extension_id();
130 Profile* profile(); 137 Profile* profile();
131 138
132 // The arguments to the API. Only non-null if argument were specified. 139 // The arguments to the API. Only non-null if argument were specified.
133 Value* args_; 140 scoped_ptr<Value> args_;
134 141
135 // The result of the API. This should be populated by the derived class before 142 // The result of the API. This should be populated by the derived class before
136 // SendResponse() is called. 143 // SendResponse() is called.
137 scoped_ptr<Value> result_; 144 scoped_ptr<Value> result_;
138 145
139 // Any detailed error from the API. This should be populated by the derived 146 // Any detailed error from the API. This should be populated by the derived
140 // class before Run() returns. 147 // class before Run() returns.
141 std::string error_; 148 std::string error_;
142 149
143 // Any class that gets a malformed message should set this to true before 150 // Any class that gets a malformed message should set this to true before
(...skipping 23 matching lines...) Expand all
167 } 174 }
168 175
169 protected: 176 protected:
170 virtual ~SyncExtensionFunction() {} 177 virtual ~SyncExtensionFunction() {}
171 178
172 private: 179 private:
173 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); 180 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction);
174 }; 181 };
175 182
176 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_ 183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browser_actions_api.cc ('k') | chrome/browser/extensions/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698