Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TEST_UTILS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 // before running it. | 43 // before running it. |
| 44 scoped_refptr<Extension> CreateEmptyExtension(); | 44 scoped_refptr<Extension> CreateEmptyExtension(); |
| 45 | 45 |
| 46 enum RunFunctionFlags { | 46 enum RunFunctionFlags { |
| 47 NONE = 0, | 47 NONE = 0, |
| 48 INCLUDE_INCOGNITO = 1 << 0 | 48 INCLUDE_INCOGNITO = 1 << 0 |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // Run |function| with |args| and return the resulting error. Adds an error to | 51 // Run |function| with |args| and return the resulting error. Adds an error to |
| 52 // the current test if |function| returns a result. The caller releases | 52 // the current test if |function| returns a result. The caller releases |
| 53 // ownership of |function|. | 53 // ownership of |function|. |
|
asargent_no_longer_on_chrome
2011/11/18 23:08:18
nit: remove this line about caller releasing owner
| |
| 54 // | |
| 55 // For these and all Run* methods, the caller must hold a reference to | |
| 56 // the function during the lifetime of the method. | |
| 54 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, | 57 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
| 55 const std::string& args, | 58 const std::string& args, |
| 56 Browser* browser, | 59 Browser* browser, |
| 57 RunFunctionFlags flags); | 60 RunFunctionFlags flags); |
| 58 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, | 61 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, |
| 59 const std::string& args, | 62 const std::string& args, |
| 60 Browser* browser); | 63 Browser* browser); |
| 61 | 64 |
| 62 // Run |function| with |args| and return the result. Adds an error to the | 65 // Run |function| with |args| and return the result. Adds an error to the |
| 63 // current test if |function| returns an error. The caller releases ownership of | 66 // current test if |function| returns an error. The caller releases ownership of |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 80 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs | 83 // TODO(aa): I'm concerned that this style won't scale to all the bits and bobs |
| 81 // we're going to need to frob for all the different extension functions. But we | 84 // we're going to need to frob for all the different extension functions. But we |
| 82 // can refactor when we see what is needed. | 85 // can refactor when we see what is needed. |
| 83 void RunFunction(UIThreadExtensionFunction* function, | 86 void RunFunction(UIThreadExtensionFunction* function, |
| 84 const std::string& args, | 87 const std::string& args, |
| 85 Browser* browser, | 88 Browser* browser, |
| 86 RunFunctionFlags flags); | 89 RunFunctionFlags flags); |
| 87 | 90 |
| 88 // Similar to RunFunction, but doesn't return until |function| calls | 91 // Similar to RunFunction, but doesn't return until |function| calls |
| 89 // SendResponse. Returns the value |function| passed to SendResponse. | 92 // SendResponse. Returns the value |function| passed to SendResponse. |
| 90 bool RunAsyncFunction(AsyncExtensionFunction* function, | 93 // |
| 94 // See above re holding reference. | |
| 95 bool RunAsyncFunction(UIThreadExtensionFunction* function, | |
|
asargent_no_longer_on_chrome
2011/11/18 23:08:18
I thought Aaron's idea was that we want to get rid
| |
| 91 const std::string& args, | 96 const std::string& args, |
| 92 Browser* browser, | 97 Browser* browser, |
| 93 RunFunctionFlags flags); | 98 RunFunctionFlags flags); |
| 94 | 99 |
| 95 } // namespace extension_function_test_utils | 100 } // namespace extension_function_test_utils |
| 96 | 101 |
| 97 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ | 102 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_TEST_UTILS_H_ |
| OLD | NEW |