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

Side by Side Diff: testing/multiprocess_func_list.cc

Issue 10387218: Make GlobalDescriptors::MaybeGet return -1 when the key is not found. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied Jeremy's suggestions + sync. Created 8 years, 6 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 "multiprocess_func_list.h" 5 #include "multiprocess_func_list.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 // Helper functions to maintain mapping of "test name"->test func. 9 // Helper functions to maintain mapping of "test name"->test func.
10 // The information is accessed via a global map. 10 // The information is accessed via a global map.
11 namespace multi_process_function_list { 11 namespace multi_process_function_list {
12 12
13 namespace { 13 namespace {
14 14
15 typedef std::map<std::string, ChildFunctionPtr> MultiProcessTestMap; 15 typedef std::map<std::string, ChildFunctionPtr> MultiProcessTestMap;
16 16
17 // Retrieve a reference to the global 'func name' -> func ptr map. 17 // Retrieve a reference to the global 'func name' -> func ptr map.
18 MultiProcessTestMap &GetMultiprocessFuncMap() { 18 MultiProcessTestMap &GetMultiprocessFuncMap() {
19 static MultiProcessTestMap test_name_to_func_ptr_map; 19 static MultiProcessTestMap test_name_to_func_ptr_map;
20 return test_name_to_func_ptr_map; 20 return test_name_to_func_ptr_map;
21 } 21 }
22 22
23 } // namespace 23 } // namespace
24 24
25 AppendMultiProcessTest::AppendMultiProcessTest(std::string test_name, 25 AppendMultiProcessTest::AppendMultiProcessTest(
26 ChildFunctionPtr func_ptr) { 26 std::string test_name,
27 GetMultiprocessFuncMap()[test_name] = func_ptr; 27 ChildFunctionPtr main_func_ptr,
28 ChildFunctionPtr setup_func_ptr) {
29 if (setup_func_ptr)
30 (*setup_func_ptr)();
31 GetMultiprocessFuncMap()[test_name] = main_func_ptr;
28 } 32 }
29 33
30 int InvokeChildProcessTest(std::string test_name) { 34 int InvokeChildProcessTest(std::string test_name) {
31 MultiProcessTestMap &func_lookup_table = GetMultiprocessFuncMap(); 35 MultiProcessTestMap &func_lookup_table = GetMultiprocessFuncMap();
32 MultiProcessTestMap::iterator it = func_lookup_table.find(test_name); 36 MultiProcessTestMap::iterator it = func_lookup_table.find(test_name);
33 if (it != func_lookup_table.end()) { 37 if (it != func_lookup_table.end()) {
34 ChildFunctionPtr func = it->second; 38 ChildFunctionPtr func = it->second;
35 if (func) { 39 if (func) {
36 return (*func)(); 40 return (*func)();
37 } 41 }
38 } 42 }
39 43
40 return -1; 44 return -1;
41 } 45 }
42 46
43 } // namespace multi_process_function_list 47 } // namespace multi_process_function_list
OLDNEW
« testing/multiprocess_func_list.h ('K') | « testing/multiprocess_func_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698