media/webrtc/trunk/testing/multiprocess_func_list.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/testing/multiprocess_func_list.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +// Copyright (c) 2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "multiprocess_func_list.h"
     1.9 +
    1.10 +#include <map>
    1.11 +
    1.12 +// Helper functions to maintain mapping of "test name"->test func.
    1.13 +// The information is accessed via a global map.
    1.14 +namespace multi_process_function_list {
    1.15 +
    1.16 +namespace {
    1.17 +
    1.18 +typedef std::map<std::string, ChildFunctionPtr> MultiProcessTestMap;
    1.19 +
    1.20 +// Retrieve a reference to the global 'func name' -> func ptr map.
    1.21 +MultiProcessTestMap &GetMultiprocessFuncMap() {
    1.22 +  static MultiProcessTestMap test_name_to_func_ptr_map;
    1.23 +  return test_name_to_func_ptr_map;
    1.24 +}
    1.25 +
    1.26 +}  // namespace
    1.27 +
    1.28 +AppendMultiProcessTest::AppendMultiProcessTest(std::string test_name,
    1.29 +                                               ChildFunctionPtr func_ptr) {
    1.30 +  GetMultiprocessFuncMap()[test_name] = func_ptr;
    1.31 +}
    1.32 +
    1.33 +int InvokeChildProcessTest(std::string test_name) {
    1.34 +  MultiProcessTestMap &func_lookup_table = GetMultiprocessFuncMap();
    1.35 +  MultiProcessTestMap::iterator it = func_lookup_table.find(test_name);
    1.36 +  if (it != func_lookup_table.end()) {
    1.37 +    ChildFunctionPtr func = it->second;
    1.38 +    if (func) {
    1.39 +      return (*func)();
    1.40 +    }
    1.41 +  }
    1.42 +
    1.43 +  return -1;
    1.44 +}
    1.45 +
    1.46 +}  // namespace multi_process_function_list

mercurial