0

Move usb_ids to public folder and clean up the dependency.

//device/usb will be moved to //services/device, so break the
dependencies on //device/usb outside //device and //services.

Bug: 699790
Change-Id: I0cfdccec6d16f54cd4588196e0559cb088990a05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1600834
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Donna Wu <donna.wu@intel.com>
Cr-Commit-Position: refs/heads/master@{#658951}
This commit is contained in:
Donna Wu
2019-05-13 02:56:18 +00:00
committed by Commit Bot
parent 1cf43fe065
commit ee09a3493a
23 changed files with 107 additions and 110 deletions

@ -2028,6 +2028,7 @@ jumbo_split_static_library("browser") {
"//content/public/common:service_names",
"//crypto",
"//crypto:platform",
"//device/base",
"//device/fido",
"//device/gamepad/public/cpp:switches",
"//device/usb/public/cpp",

@ -33,7 +33,7 @@ include_rules = [
"+device/bluetooth",
"+device/fido",
"+device/gamepad/public/cpp",
"+device/usb",
"+device/usb/public",
"+device/vr/buildflags/buildflags.h",
"+device/vr/public",
"+extensions/browser",

@ -22,7 +22,6 @@
#include "device/usb/public/cpp/usb_utils.h"
#include "device/usb/public/mojom/device_enumeration_options.mojom.h"
#include "device/usb/public/mojom/device_manager.mojom.h"
#include "device/usb/usb_device.h"
#include "ui/base/l10n/l10n_util.h"
using device::mojom::UsbDeviceInfo;

@ -1117,6 +1117,7 @@ jumbo_static_library("extensions") {
"//third_party/iaccessible2",
"//third_party/isimpledom",
]
libs = [ "setupapi.lib" ]
} else if (use_aura && !is_chromeos) {
sources += [
"system_display/display_info_provider_aura.cc",

@ -20,8 +20,8 @@
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/common/content_settings.h"
#include "content/public/common/service_manager_connection.h"
#include "device/usb/public/cpp/usb_ids.h"
#include "device/usb/public/mojom/device.mojom.h"
#include "device/usb/usb_ids.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/l10n/l10n_util.h"

@ -26,7 +26,7 @@
#include "url/gurl.h"
#if !defined(OS_ANDROID)
#include "device/usb/usb_ids.h"
#include "device/usb/public/cpp/usb_ids.h"
#endif // !defined(OS_ANDROID)
using content::RenderFrameHost;

@ -374,7 +374,7 @@ static_library("common") {
public_deps += [
"//chrome/common/extensions/api",
"//chrome/common/extensions/api:extensions_features",
"//device/usb",
"//device/usb/public/cpp",
"//extensions:extensions_resources",
"//extensions/common",
"//extensions/common:core_api_provider",

@ -1,6 +1,5 @@
include_rules = [
"+components/policy/core/common",
"+device/usb", # For UsbDevicePermission
"+extensions/grit",
"+extensions/strings/grit",
"+extensions/test",

@ -51,7 +51,6 @@ template("implement_content_app") {
"//content/public/android:jni",
"//device/bluetooth",
"//device/gamepad",
"//device/usb",
"//gpu",
"//media",
"//media/capture",

@ -3,7 +3,6 @@ include_rules = [
"+content",
"+device/bluetooth",
"+device/gamepad",
"+device/usb",
# For loading V8's initial snapshot from external files.
"+gin/public/isolate_holder.h",
"+gin/public/snapshot_fd_data.h",

@ -199,7 +199,7 @@ test("device_unittests") {
]
if (!is_android) {
sources += [ "usb/usb_ids_unittest.cc" ]
sources += [ "usb/public/cpp/usb_ids_unittest.cc" ]
}
}

@ -11,10 +11,15 @@ if (is_android) {
import("//build/config/android/rules.gni") # For generate_jni().
}
source_ids = "//third_party/usb_ids/usb.ids"
generated_ids = "$target_gen_dir/usb_ids_gen.cc"
static_library("usb") {
# Only the device_usb_mojo and tests in //device folder can depend on it.
visibility = [
":*",
"//device:*",
"//device/usb/mojo:*",
"//services/device:*",
]
sources = [
"usb_configuration_android.cc",
"usb_configuration_android.h",
@ -71,12 +76,7 @@ static_library("usb") {
if (is_android) {
deps += [ ":jni_headers" ]
} else {
deps += [ ":usb_device_ids" ]
sources += [
"usb_ids.cc",
"usb_ids.h",
generated_ids,
]
deps += [ "//device/usb/public/cpp" ]
}
if (is_win || is_mac) {
@ -152,25 +152,6 @@ static_library("test_support") {
]
}
action("usb_device_ids") {
script = "//device/usb/tools/usb_ids.py"
inputs = [
source_ids,
]
outputs = [
generated_ids,
]
args = [
"-i",
rebase_path(source_ids, root_build_dir),
"-o",
rebase_path(generated_ids, root_build_dir),
]
# Only the device_usb target can depend on us.
visibility = [ ":usb" ]
}
fuzzer_test("webusb_descriptors_fuzzer") {
sources = [
"webusb_descriptors_fuzzer.cc",

@ -2,17 +2,39 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_ids = "//third_party/usb_ids/usb.ids"
generated_ids = "$target_gen_dir/usb_ids_gen.cc"
action("usb_device_ids") {
script = "//device/usb/public/tools/usb_ids.py"
inputs = [
source_ids,
]
outputs = [
generated_ids,
]
args = [
"-i",
rebase_path(source_ids, root_build_dir),
"-o",
rebase_path(generated_ids, root_build_dir),
]
# Only the device_usb_public_cpp target can depend on us.
visibility = [ ":cpp" ]
}
source_set("cpp") {
sources = [
"usb_ids.cc",
"usb_ids.h",
"usb_utils.cc",
"usb_utils.h",
generated_ids,
]
deps = [
# TODO(donna.wu@intel.com): remove this when usb_ids.h/cpp have been
# moved to the public folder.
"//device/usb",
":usb_device_ids",
"//device/usb/public/mojom",
]
}

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/usb/usb_ids.h"
#include "device/usb/public/cpp/usb_ids.h"
#include <stdlib.h>

@ -1,11 +1,59 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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 DEVICE_USB_PUBLIC_CPP_USB_IDS_H_
#define DEVICE_USB_PUBLIC_CPP_USB_IDS_H_
// This header is just used to expose usb_ids.h to outside users.
#include "device/usb/usb_ids.h"
#include <stddef.h>
#include <stdint.h>
#include "base/macros.h"
namespace device {
struct UsbProduct {
const uint16_t id;
const char* name;
};
struct UsbVendor {
const uint16_t id;
const char* name;
const size_t product_size;
const UsbProduct* products;
};
// UsbIds provides a static mapping from a vendor ID to a name, as well as a
// mapping from a vendor/product ID pair to a product name.
class UsbIds {
public:
// Gets the name of the vendor who owns |vendor_id|. Returns NULL if the
// specified |vendor_id| does not exist.
static const char* GetVendorName(uint16_t vendor_id);
// Gets the name of a product belonging to a specific vendor. If either
// |vendor_id| refers to a vendor that does not exist, or |vendor_id| is valid
// but |product_id| refers to a product that does not exist, this method
// returns NULL.
static const char* GetProductName(uint16_t vendor_id, uint16_t product_id);
private:
UsbIds();
~UsbIds();
// Finds the static UsbVendor associated with |vendor_id|. Returns NULL if no
// such vendor exists.
static const UsbVendor* FindVendor(uint16_t vendor_id);
// These fields are defined in a generated file. See device/usb/usb.gyp for
// more information on how they are generated.
static const size_t vendor_size_;
static const UsbVendor vendors_[];
DISALLOW_COPY_AND_ASSIGN(UsbIds);
};
} // namespace device
#endif // DEVICE_USB_PUBLIC_CPP_USB_IDS_H_

@ -6,7 +6,7 @@
#include <string>
#include "device/usb/usb_ids.h"
#include "device/usb/public/cpp/usb_ids.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@ -26,8 +26,8 @@ TEST(UsbIdsTest, GetVendorName) {
TEST(UsbIdsTest, GetProductName) {
EXPECT_EQ(NULL, UsbIds::GetProductName(0, 0));
EXPECT_EQ(NULL, UsbIds::GetProductName(kGoogleVendorId, 0));
EXPECT_EQ(std::string("Nexus S"), UsbIds::GetProductName(kGoogleVendorId,
kNexusSProductId));
EXPECT_EQ(std::string("Nexus S"),
UsbIds::GetProductName(kGoogleVendorId, kNexusSProductId));
}
} // namespace device

@ -93,7 +93,7 @@ if __name__ == "__main__":
#include <stddef.h>
#include "device/usb/usb_ids.h"
#include "device/usb/public/cpp/usb_ids.h"
namespace device {

@ -1,59 +0,0 @@
// Copyright (c) 2012 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 DEVICE_USB_USB_IDS_H_
#define DEVICE_USB_USB_IDS_H_
#include <stddef.h>
#include <stdint.h>
#include "base/macros.h"
namespace device {
struct UsbProduct {
const uint16_t id;
const char* name;
};
struct UsbVendor {
const uint16_t id;
const char* name;
const size_t product_size;
const UsbProduct* products;
};
// UsbIds provides a static mapping from a vendor ID to a name, as well as a
// mapping from a vendor/product ID pair to a product name.
class UsbIds {
public:
// Gets the name of the vendor who owns |vendor_id|. Returns NULL if the
// specified |vendor_id| does not exist.
static const char* GetVendorName(uint16_t vendor_id);
// Gets the name of a product belonging to a specific vendor. If either
// |vendor_id| refers to a vendor that does not exist, or |vendor_id| is valid
// but |product_id| refers to a product that does not exist, this method
// returns NULL.
static const char* GetProductName(uint16_t vendor_id, uint16_t product_id);
private:
UsbIds();
~UsbIds();
// Finds the static UsbVendor associated with |vendor_id|. Returns NULL if no
// such vendor exists.
static const UsbVendor* FindVendor(uint16_t vendor_id);
// These fields are defined in a generated file. See device/usb/usb.gyp for
// more information on how they are generated.
static const size_t vendor_size_;
static const UsbVendor vendors_[];
DISALLOW_COPY_AND_ASSIGN(UsbIds);
};
} // namespace device
#endif // DEVICE_USB_USB_IDS_H_

@ -24,6 +24,7 @@ source_set("bluetooth") {
]
deps = [
"//components/device_event_log",
"//content/public/browser",
"//extensions/common/api",
]

@ -5,7 +5,7 @@ include_rules = [
"+chromeos/audio",
"+crypto",
"+device/udev_linux",
"+device/usb",
"+device/usb/public",
"+gpu",
"+jni",
"+mojo/public/cpp/bindings/callback_helpers.h",

@ -137,7 +137,7 @@ component("midi") {
}
if (is_win) {
deps += [ "//device/usb" ]
deps += [ "//device/usb/public/cpp" ]
sources += [
"midi_manager_win.cc",
"midi_manager_win.h",
@ -145,6 +145,8 @@ component("midi") {
"midi_manager_winrt.h",
]
libs += [ "setupapi.lib" ]
# This library is included in base in static builds.
if (is_component_build) {
libs += [ "cfgmgr32.lib" ]

@ -13,7 +13,9 @@
#include <algorithm>
#include <limits>
#include <map>
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
@ -27,7 +29,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/win/windows_version.h"
#include "device/usb/usb_ids.h"
#include "device/usb/public/cpp/usb_ids.h"
#include "media/midi/message_util.h"
#include "media/midi/midi_manager_winrt.h"
#include "media/midi/midi_service.h"

@ -6,6 +6,8 @@
#pragma warning(disable : 4467)
#define INITGUID
#include <windows.h>
#include <cfgmgr32.h>