OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/values.h" | 5 #include "base/values.h" |
6 #include "chrome/browser/browser_process_impl.h" | 6 #include "chrome/browser/browser_process_impl.h" |
7 #include "chrome/browser/extensions/api/socket/socket_api.h" | 7 #include "chrome/browser/extensions/api/socket/socket_api.h" |
8 #include "chrome/browser/extensions/extension_function_test_utils.h" | 8 #include "chrome/browser/extensions/extension_function_test_utils.h" |
9 #include "chrome/browser/extensions/test_extension_system.h" | 9 #include "chrome/browser/extensions/test_extension_system.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 TestExtensionSystem* system = static_cast<TestExtensionSystem*>( | 25 TestExtensionSystem* system = static_cast<TestExtensionSystem*>( |
26 ExtensionSystem::Get(browser()->profile())); | 26 ExtensionSystem::Get(browser()->profile())); |
27 system->CreateSocketManager(); | 27 system->CreateSocketManager(); |
28 | 28 |
29 extension_ = utils::CreateEmptyExtensionWithLocation( | 29 extension_ = utils::CreateEmptyExtensionWithLocation( |
30 extensions::Extension::LOAD); | 30 extensions::Extension::LOAD); |
31 } | 31 } |
32 | 32 |
33 base::Value* RunFunctionWithExtension( | 33 base::Value* RunFunctionWithExtension( |
34 UIThreadExtensionFunction* function, const std::string& args) { | 34 UIThreadExtensionFunction* function, const std::string& args) { |
| 35 scoped_refptr<UIThreadExtensionFunction> delete_function(function); |
35 function->set_extension(extension_.get()); | 36 function->set_extension(extension_.get()); |
36 return utils::RunFunctionAndReturnSingleResult(function, args, browser()); | 37 return utils::RunFunctionAndReturnSingleResult(function, args, browser()); |
37 } | 38 } |
38 | 39 |
39 base::DictionaryValue* RunFunctionAndReturnDict( | 40 base::DictionaryValue* RunFunctionAndReturnDict( |
40 UIThreadExtensionFunction* function, const std::string& args) { | 41 UIThreadExtensionFunction* function, const std::string& args) { |
41 base::Value* result = RunFunctionWithExtension(function, args); | 42 base::Value* result = RunFunctionWithExtension(function, args); |
42 return result ? utils::ToDictionary(result) : NULL; | 43 return result ? utils::ToDictionary(result) : NULL; |
43 } | 44 } |
44 | 45 |
(...skipping 29 matching lines...) Expand all Loading... |
74 ASSERT_TRUE(result.get()); | 75 ASSERT_TRUE(result.get()); |
75 } | 76 } |
76 { | 77 { |
77 std::string error = RunFunctionAndReturnError( | 78 std::string error = RunFunctionAndReturnError( |
78 new SocketCreateFunction(), "[\"nonexistent-socket-type\"]"); | 79 new SocketCreateFunction(), "[\"nonexistent-socket-type\"]"); |
79 ASSERT_FALSE(error.empty()) << "Expected error. Got nothing instead."; | 80 ASSERT_FALSE(error.empty()) << "Expected error. Got nothing instead."; |
80 } | 81 } |
81 } | 82 } |
82 | 83 |
83 } // namespace extensions | 84 } // namespace extensions |
OLD | NEW |