media/webrtc/trunk/testing/multiprocess_func_list.cc

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial