#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/process/process_handle.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/stl_util.h"
#include "base/strings/escape.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "net/base/elements_upload_data_stream.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/proxy_resolution/configured_proxy_resolution_service.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_test_util.h"
#include "services/device/test/usb_test_gadget.h"
#include "services/device/usb/usb_device.h"
#include "services/device/usb/usb_device_handle.h"
#include "services/device/usb/usb_service.h"
#include "url/gurl.h"
namespace device {
class UsbTestGadgetImpl : public UsbTestGadget { … };
namespace {
static const char kCommandLineSwitch[] = …;
static const int kReenumeratePeriod = …;
struct UsbTestGadgetConfiguration { … };
static const struct UsbTestGadgetConfiguration kConfigurations[] = …;
bool ReadFile(const base::FilePath& file_path, std::string* content) { … }
bool ReadLocalVersion(std::string* version) { … }
bool ReadLocalPackage(std::string* package) { … }
class URLRequestContextGetter : public net::URLRequestContextGetter { … };
std::unique_ptr<net::URLRequest> CreateSimpleRequest(
net::URLRequestContext& request_context,
net::URLRequest::Delegate* delegate,
const GURL& url,
const std::string& form_data_type,
const std::string& form_data) { … }
int SimplePOSTRequest(
const GURL& url,
const std::string& form_data) { … }
class UsbGadgetFactory : public UsbService::Observer { … };
class DeviceAddListener : public UsbService::Observer { … };
class DeviceRemoveListener : public UsbService::Observer { … };
}
bool UsbTestGadget::IsTestEnabled() { … }
std::unique_ptr<UsbTestGadget> UsbTestGadget::Claim(
UsbService* usb_service,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { … }
UsbTestGadgetImpl::UsbTestGadgetImpl(
UsbService* usb_service,
scoped_refptr<UsbDevice> device)
: … { … }
UsbTestGadgetImpl::~UsbTestGadgetImpl() { … }
UsbDevice* UsbTestGadgetImpl::GetDevice() const { … }
bool UsbTestGadgetImpl::Unclaim() { … }
bool UsbTestGadgetImpl::SetType(Type type) { … }
bool UsbTestGadgetImpl::Disconnect() { … }
bool UsbTestGadgetImpl::Reconnect() { … }
}