Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #include "multiprocess_func_list.h" |
michael@0 | 6 | |
michael@0 | 7 | #include <map> |
michael@0 | 8 | |
michael@0 | 9 | // Helper functions to maintain mapping of "test name"->test func. |
michael@0 | 10 | // The information is accessed via a global map. |
michael@0 | 11 | namespace multi_process_function_list { |
michael@0 | 12 | |
michael@0 | 13 | namespace { |
michael@0 | 14 | |
michael@0 | 15 | typedef std::map<std::string, ChildFunctionPtr> MultiProcessTestMap; |
michael@0 | 16 | |
michael@0 | 17 | // Retrieve a reference to the global 'func name' -> func ptr map. |
michael@0 | 18 | MultiProcessTestMap &GetMultiprocessFuncMap() { |
michael@0 | 19 | static MultiProcessTestMap test_name_to_func_ptr_map; |
michael@0 | 20 | return test_name_to_func_ptr_map; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | } // namespace |
michael@0 | 24 | |
michael@0 | 25 | AppendMultiProcessTest::AppendMultiProcessTest(std::string test_name, |
michael@0 | 26 | ChildFunctionPtr func_ptr) { |
michael@0 | 27 | GetMultiprocessFuncMap()[test_name] = func_ptr; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | int InvokeChildProcessTest(std::string test_name) { |
michael@0 | 31 | MultiProcessTestMap &func_lookup_table = GetMultiprocessFuncMap(); |
michael@0 | 32 | MultiProcessTestMap::iterator it = func_lookup_table.find(test_name); |
michael@0 | 33 | if (it != func_lookup_table.end()) { |
michael@0 | 34 | ChildFunctionPtr func = it->second; |
michael@0 | 35 | if (func) { |
michael@0 | 36 | return (*func)(); |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | return -1; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | } // namespace multi_process_function_list |