michael@0: // Copyright (c) 2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include "multiprocess_func_list.h" michael@0: michael@0: #include michael@0: michael@0: // Helper functions to maintain mapping of "test name"->test func. michael@0: // The information is accessed via a global map. michael@0: namespace multi_process_function_list { michael@0: michael@0: namespace { michael@0: michael@0: typedef std::map MultiProcessTestMap; michael@0: michael@0: // Retrieve a reference to the global 'func name' -> func ptr map. michael@0: MultiProcessTestMap &GetMultiprocessFuncMap() { michael@0: static MultiProcessTestMap test_name_to_func_ptr_map; michael@0: return test_name_to_func_ptr_map; michael@0: } michael@0: michael@0: } // namespace michael@0: michael@0: AppendMultiProcessTest::AppendMultiProcessTest(std::string test_name, michael@0: ChildFunctionPtr func_ptr) { michael@0: GetMultiprocessFuncMap()[test_name] = func_ptr; michael@0: } michael@0: michael@0: int InvokeChildProcessTest(std::string test_name) { michael@0: MultiProcessTestMap &func_lookup_table = GetMultiprocessFuncMap(); michael@0: MultiProcessTestMap::iterator it = func_lookup_table.find(test_name); michael@0: if (it != func_lookup_table.end()) { michael@0: ChildFunctionPtr func = it->second; michael@0: if (func) { michael@0: return (*func)(); michael@0: } michael@0: } michael@0: michael@0: return -1; michael@0: } michael@0: michael@0: } // namespace multi_process_function_list