Skip to content

Commit

Permalink
[ppapi] Merged two identical interface_name
Browse files Browse the repository at this point in the history
In jumbo build experiments, two cc files both defined
interface_name<PPB_InputEvent_1_0>() which clashed since in
jumbo builds many cc files are compiled in the same translation unit.

This moves the shared code to a shared file.

Bug: 898475
Change-Id: I9ce58e837d663cb5c15ba2596c22812a41def4c0
Reviewed-on: https://chromium-review.googlesource.com/c/1297148
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Sam Clegg <sbc@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#607601}
  • Loading branch information
bratell-at-opera authored and Commit Bot committed Nov 13, 2018
1 parent 5c64a81 commit 0781150
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions native_client_sdk/src/libraries/ppapi_cpp/library.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
'host_resolver.h',
'image_data.h',
'input_event.h',
'input_event_interface_name.h',
'instance.h',
'instance_handle.h',
'logging.h',
Expand Down
1 change: 1 addition & 0 deletions ppapi/cpp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ source_set("objects") {
"image_data.h",
"input_event.cc",
"input_event.h",
"input_event_interface_name.h",
"instance.cc",
"instance.h",
"instance_handle.cc",
Expand Down
5 changes: 1 addition & 4 deletions ppapi/cpp/input_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ppapi/cpp/input_event.h"

#include "ppapi/cpp/input_event_interface_name.h"
#include "ppapi/cpp/instance_handle.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
Expand All @@ -15,10 +16,6 @@ namespace pp {

namespace {

template <> const char* interface_name<PPB_InputEvent_1_0>() {
return PPB_INPUT_EVENT_INTERFACE_1_0;
}

template <> const char* interface_name<PPB_KeyboardInputEvent_1_2>() {
return PPB_KEYBOARD_INPUT_EVENT_INTERFACE_1_2;
}
Expand Down
24 changes: 24 additions & 0 deletions ppapi/cpp/input_event_interface_name.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PPAPI_CPP_INPUT_EVENT_INTERFACE_NAME_H_
#define PPAPI_CPP_INPUT_EVENT_INTERFACE_NAME_H_

#include "ppapi/c/ppb_input_event.h"
#include "ppapi/cpp/module_impl.h"

namespace pp {

namespace {

// This implementation is shared between instance.cc and input_event.cc
template <>
const char* interface_name<PPB_InputEvent_1_0>() {
return PPB_INPUT_EVENT_INTERFACE_1_0;
}

} // namespace
} // namespace pp

#endif // PPAPI_CPP_INPUT_EVENT_INTERFACE_NAME_H_
5 changes: 1 addition & 4 deletions ppapi/cpp/instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/graphics_3d.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/input_event_interface_name.h"
#include "ppapi/cpp/instance_handle.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/message_handler.h"
Expand All @@ -33,10 +34,6 @@ template <> const char* interface_name<PPB_Console_1_0>() {
return PPB_CONSOLE_INTERFACE_1_0;
}

template <> const char* interface_name<PPB_InputEvent_1_0>() {
return PPB_INPUT_EVENT_INTERFACE_1_0;
}

template <> const char* interface_name<PPB_Instance_1_0>() {
return PPB_INSTANCE_INTERFACE_1_0;
}
Expand Down
5 changes: 2 additions & 3 deletions ppapi/cpp/module_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ namespace {

// Specialize this function to return the interface string corresponding to the
// PP?_XXX structure.
template <typename T> const char* interface_name() {
return NULL;
}
template <typename T>
const char* interface_name();

template <typename T> inline T const* get_interface() {
static T const* funcs = reinterpret_cast<T const*>(
Expand Down

0 comments on commit 0781150

Please sign in to comment.