Make Windows build work
Various warning fixes, and deletions of unused stuff.
Change-Id: I0682b450b5fca0de7c1d1763e1e011c258669015
Reviewed-on: https://gn-review.googlesource.com/1380
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/README.md b/README.md
index 486b14d..498b017 100644
--- a/README.md
+++ b/README.md
@@ -7,5 +7,5 @@
git clone https://gn.googlesource.com/gn
cd gn
- build/gen.py
+ python build/gen.py
ninja -C out
diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc
index ed4f147..25f21ca 100644
--- a/base/metrics/field_trial.cc
+++ b/base/metrics/field_trial.cc
@@ -1229,7 +1229,8 @@
#if defined(OS_FUCHSIA)
zx_handle_t handle = static_cast<zx_handle_t>(field_trial_handle);
#elif defined(OS_WIN)
- HANDLE handle = reinterpret_cast<HANDLE>(field_trial_handle);
+ HANDLE handle =
+ reinterpret_cast<HANDLE>(static_cast<uintptr_t>(field_trial_handle));
if (base::IsCurrentProcessElevated()) {
// base::LaunchElevatedProcess doesn't have a way to duplicate the handle,
// but this process can since by definition it's not sandboxed.
diff --git a/base/task_scheduler/scheduler_worker_pool_impl.cc b/base/task_scheduler/scheduler_worker_pool_impl.cc
index b309bbd..0e0c107 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl.cc
+++ b/base/task_scheduler/scheduler_worker_pool_impl.cc
@@ -31,7 +31,6 @@
#if defined(OS_WIN)
#include "base/win/scoped_com_initializer.h"
#include "base/win/scoped_windows_thread_environment.h"
-#include "base/win/scoped_winrt_initializer.h"
#include "base/win/windows_version.h"
#endif // defined(OS_WIN)
@@ -152,10 +151,6 @@
// returned a non-empty sequence and DidRunTask() hasn't been called yet).
bool is_running_task_ = false;
-#if defined(OS_WIN)
- std::unique_ptr<win::ScopedWindowsThreadEnvironment> win_thread_environment_;
-#endif // defined(OS_WIN)
-
// Verifies that specific calls are always made from the worker thread.
THREAD_CHECKER(worker_thread_checker_);
@@ -405,18 +400,6 @@
#endif
}
-#if defined(OS_WIN)
- if (outer_->worker_environment_ == WorkerEnvironment::COM_MTA) {
- if (win::GetVersion() >= win::VERSION_WIN8) {
- win_thread_environment_ = std::make_unique<win::ScopedWinrtInitializer>();
- } else {
- win_thread_environment_ = std::make_unique<win::ScopedCOMInitializer>(
- win::ScopedCOMInitializer::kMTA);
- }
- DCHECK(win_thread_environment_->Succeeded());
- }
-#endif // defined(OS_WIN)
-
DCHECK_EQ(num_tasks_since_last_wait_, 0U);
PlatformThread::SetName(
@@ -588,10 +571,6 @@
}
}
#endif
-
-#if defined(OS_WIN)
- win_thread_environment_.reset();
-#endif // defined(OS_WIN)
}
void SchedulerWorkerPoolImpl::SchedulerWorkerDelegateImpl::
diff --git a/base/task_scheduler/task_tracker.cc b/base/task_scheduler/task_tracker.cc
index ab46b9e..5c98b5c 100644
--- a/base/task_scheduler/task_tracker.cc
+++ b/base/task_scheduler/task_tracker.cc
@@ -454,15 +454,6 @@
DCHECK(latency_histogram_type == LatencyHistogramType::TASK_LATENCY ||
latency_histogram_type == LatencyHistogramType::HEARTBEAT_LATENCY);
- auto& histograms =
- latency_histogram_type == LatencyHistogramType::TASK_LATENCY
- ? task_latency_histograms_
- : heartbeat_latency_histograms_;
- histograms[static_cast<int>(task_traits.priority())]
- [task_traits.may_block() || task_traits.with_base_sync_primitives()
- ? 1
- : 0]
- ->AddTimeMicrosecondsGranularity(task_latency);
}
void TaskTracker::RunOrSkipTask(Task task,
diff --git a/base/trace_event/trace_event_etw_export_win.cc b/base/trace_event/trace_event_etw_export_win.cc
deleted file mode 100644
index 993a222..0000000
--- a/base/trace_event/trace_event_etw_export_win.cc
+++ /dev/null
@@ -1,380 +0,0 @@
-// Copyright 2015 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.
-
-#include "base/trace_event/trace_event_etw_export_win.h"
-
-#include <stddef.h>
-
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-#include "base/strings/string_tokenizer.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/threading/platform_thread.h"
-#include "base/trace_event/trace_event.h"
-#include "base/trace_event/trace_event_impl.h"
-
-#include <windows.h>
-
-// The GetProcAddress technique is borrowed from
-// https://github.com/google/UIforETW/tree/master/ETWProviders
-//
-// EVNTAPI is used in evntprov.h which is included by chrome_events_win.h.
-// We define EVNTAPI without the DECLSPEC_IMPORT specifier so that we can
-// implement these functions locally instead of using the import library, and
-// can therefore still run on Windows XP.
-#define EVNTAPI __stdcall
-// Include the event register/write/unregister macros compiled from the manifest
-// file. Note that this includes evntprov.h which requires a Vista+ Windows SDK.
-//
-// In SHARED_INTERMEDIATE_DIR.
-#include "base/trace_event/etw_manifest/chrome_events_win.h" // NOLINT
-
-namespace {
-// |kFilteredEventGroupNames| contains the event categories that can be
-// exported individually. These categories can be enabled by passing the correct
-// keyword when starting the trace. A keyword is a 64-bit flag and we attribute
-// one bit per category. We can therefore enable a particular category by
-// setting its corresponding bit in the keyword. For events that are not present
-// in |kFilteredEventGroupNames|, we have two bits that control their
-// behaviour. When bit 61 is enabled, any event that is not disabled by default
-// (ie. doesn't start with disabled-by-default-) will be exported. Likewise,
-// when bit 62 is enabled, any event that is disabled by default will be
-// exported.
-//
-// Note that bit 63 (MSB) must always be set, otherwise tracing will be disabled
-// by ETW. Therefore, the keyword will always be greater than
-// 0x8000000000000000.
-//
-// Examples of passing keywords to the provider using xperf:
-// # This exports "benchmark" and "cc" events
-// xperf -start chrome -on Chrome:0x8000000000000009
-//
-// # This exports "gpu", "netlog" and all other events that are not disabled by
-// # default
-// xperf -start chrome -on Chrome:0xA0000000000000A0
-//
-// More info about starting a trace and keyword can be obtained by using the
-// help section of xperf (xperf -help start). Note that xperf documentation
-// refers to keywords as flags and there are two ways to enable them, using
-// group names or the hex representation. We only support the latter. Also, we
-// ignore the level.
-const char* const kFilteredEventGroupNames[] = {
- "benchmark", // 0x1
- "blink", // 0x2
- "browser", // 0x4
- "cc", // 0x8
- "evdev", // 0x10
- "gpu", // 0x20
- "input", // 0x40
- "netlog", // 0x80
- "sequence_manager", // 0x100
- "toplevel", // 0x200
- "v8", // 0x400
- "disabled-by-default-cc.debug", // 0x800
- "disabled-by-default-cc.debug.picture", // 0x1000
- "disabled-by-default-toplevel.flow", // 0x2000
- "startup"}; // 0x4000
-const char kOtherEventsGroupName[] = "__OTHER_EVENTS"; // 0x2000000000000000
-const char kDisabledOtherEventsGroupName[] =
- "__DISABLED_OTHER_EVENTS"; // 0x4000000000000000
-const uint64_t kOtherEventsKeywordBit = 1ULL << 61;
-const uint64_t kDisabledOtherEventsKeywordBit = 1ULL << 62;
-const size_t kNumberOfCategories = ARRAYSIZE(kFilteredEventGroupNames) + 2U;
-
-} // namespace
-
-namespace base {
-namespace trace_event {
-
-// This object will be created by each process. It's a background (low-priority)
-// thread that will monitor the ETW keyword for any changes.
-class TraceEventETWExport::ETWKeywordUpdateThread
- : public PlatformThread::Delegate {
- public:
- ETWKeywordUpdateThread() {}
- ~ETWKeywordUpdateThread() override {}
-
- // Implementation of PlatformThread::Delegate:
- void ThreadMain() override {
- PlatformThread::SetName("ETW Keyword Update Thread");
- TimeDelta sleep_time = TimeDelta::FromMilliseconds(kUpdateTimerDelayMs);
- while (1) {
- PlatformThread::Sleep(sleep_time);
- trace_event::TraceEventETWExport::UpdateETWKeyword();
- }
- }
-
- private:
- // Time between checks for ETW keyword changes (in milliseconds).
- unsigned int kUpdateTimerDelayMs = 1000;
-};
-
-
-TraceEventETWExport::TraceEventETWExport()
- : etw_export_enabled_(false), etw_match_any_keyword_(0ULL) {
- // Register the ETW provider. If registration fails then the event logging
- // calls will fail.
- EventRegisterChrome();
-
- // Make sure to initialize the map with all the group names. Subsequent
- // modifications will be made by the background thread and only affect the
- // values of the keys (no key addition/deletion). Therefore, the map does not
- // require a lock for access.
- for (size_t i = 0; i < ARRAYSIZE(kFilteredEventGroupNames); i++)
- categories_status_[kFilteredEventGroupNames[i]] = false;
- categories_status_[kOtherEventsGroupName] = false;
- categories_status_[kDisabledOtherEventsGroupName] = false;
- DCHECK_EQ(kNumberOfCategories, categories_status_.size());
-}
-
-TraceEventETWExport::~TraceEventETWExport() {
- EventUnregisterChrome();
-}
-
-// static
-TraceEventETWExport* TraceEventETWExport::GetInstance() {
- return Singleton<TraceEventETWExport,
- StaticMemorySingletonTraits<TraceEventETWExport>>::get();
-}
-
-// static
-void TraceEventETWExport::EnableETWExport() {
- auto* instance = GetInstance();
- if (instance && !instance->etw_export_enabled_) {
- instance->etw_export_enabled_ = true;
- // Sync the enabled categories with ETW by calling UpdateEnabledCategories()
- // that checks the keyword. Then create a thread that will call that same
- // function periodically, to make sure we stay in sync.
- instance->UpdateEnabledCategories();
- if (instance->keyword_update_thread_handle_.is_null()) {
- instance->keyword_update_thread_.reset(new ETWKeywordUpdateThread);
- PlatformThread::CreateWithPriority(
- 0, instance->keyword_update_thread_.get(),
- &instance->keyword_update_thread_handle_, ThreadPriority::BACKGROUND);
- }
- }
-}
-
-// static
-void TraceEventETWExport::DisableETWExport() {
- auto* instance = GetInstance();
- if (instance && instance->etw_export_enabled_)
- instance->etw_export_enabled_ = false;
-}
-
-// static
-bool TraceEventETWExport::IsETWExportEnabled() {
- auto* instance = GetInstance();
- return (instance && instance->etw_export_enabled_);
-}
-
-// static
-void TraceEventETWExport::AddEvent(
- char phase,
- const unsigned char* category_group_enabled,
- const char* name,
- unsigned long long id,
- int num_args,
- const char* const* arg_names,
- const unsigned char* arg_types,
- const unsigned long long* arg_values,
- const std::unique_ptr<ConvertableToTraceFormat>* convertable_values) {
- // We bail early in case exporting is disabled or no consumer is listening.
- auto* instance = GetInstance();
- if (!instance || !instance->etw_export_enabled_ || !EventEnabledChromeEvent())
- return;
-
- const char* phase_string = nullptr;
- // Space to store the phase identifier and null-terminator, when needed.
- char phase_buffer[2];
- switch (phase) {
- case TRACE_EVENT_PHASE_BEGIN:
- phase_string = "Begin";
- break;
- case TRACE_EVENT_PHASE_END:
- phase_string = "End";
- break;
- case TRACE_EVENT_PHASE_COMPLETE:
- phase_string = "Complete";
- break;
- case TRACE_EVENT_PHASE_INSTANT:
- phase_string = "Instant";
- break;
- case TRACE_EVENT_PHASE_ASYNC_BEGIN:
- phase_string = "Async Begin";
- break;
- case TRACE_EVENT_PHASE_ASYNC_STEP_INTO:
- phase_string = "Async Step Into";
- break;
- case TRACE_EVENT_PHASE_ASYNC_STEP_PAST:
- phase_string = "Async Step Past";
- break;
- case TRACE_EVENT_PHASE_ASYNC_END:
- phase_string = "Async End";
- break;
- case TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN:
- phase_string = "Nestable Async Begin";
- break;
- case TRACE_EVENT_PHASE_NESTABLE_ASYNC_END:
- phase_string = "Nestable Async End";
- break;
- case TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT:
- phase_string = "Nestable Async Instant";
- break;
- case TRACE_EVENT_PHASE_FLOW_BEGIN:
- phase_string = "Phase Flow Begin";
- break;
- case TRACE_EVENT_PHASE_FLOW_STEP:
- phase_string = "Phase Flow Step";
- break;
- case TRACE_EVENT_PHASE_FLOW_END:
- phase_string = "Phase Flow End";
- break;
- case TRACE_EVENT_PHASE_METADATA:
- phase_string = "Phase Metadata";
- break;
- case TRACE_EVENT_PHASE_COUNTER:
- phase_string = "Phase Counter";
- break;
- case TRACE_EVENT_PHASE_SAMPLE:
- phase_string = "Phase Sample";
- break;
- case TRACE_EVENT_PHASE_CREATE_OBJECT:
- phase_string = "Phase Create Object";
- break;
- case TRACE_EVENT_PHASE_SNAPSHOT_OBJECT:
- phase_string = "Phase Snapshot Object";
- break;
- case TRACE_EVENT_PHASE_DELETE_OBJECT:
- phase_string = "Phase Delete Object";
- break;
- default:
- phase_buffer[0] = phase;
- phase_buffer[1] = 0;
- phase_string = phase_buffer;
- break;
- }
-
- std::string arg_values_string[3];
- for (int i = 0; i < num_args; i++) {
- if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) {
- // Temporarily do nothing here. This function consumes 1/3 to 1/2 of
- // *total* process CPU time when ETW tracing, and many of the strings
- // created exceed WPA's 4094 byte limit and are shown as:
- // "Unable to parse data". See crbug.com/488257
- // convertable_values[i]->AppendAsTraceFormat(arg_values_string + i);
- } else {
- TraceEvent::TraceValue trace_event;
- trace_event.as_uint = arg_values[i];
- TraceEvent::AppendValueAsJSON(arg_types[i], trace_event,
- arg_values_string + i);
- }
- }
-
- EventWriteChromeEvent(
- name, phase_string, num_args > 0 ? arg_names[0] : "",
- arg_values_string[0].c_str(), num_args > 1 ? arg_names[1] : "",
- arg_values_string[1].c_str(), num_args > 2 ? arg_names[2] : "",
- arg_values_string[2].c_str());
-}
-
-// static
-void TraceEventETWExport::AddCompleteEndEvent(const char* name) {
- auto* instance = GetInstance();
- if (!instance || !instance->etw_export_enabled_ || !EventEnabledChromeEvent())
- return;
-
- EventWriteChromeEvent(name, "Complete End", "", "", "", "", "", "");
-}
-
-// static
-bool TraceEventETWExport::IsCategoryGroupEnabled(
- StringPiece category_group_name) {
- DCHECK(!category_group_name.empty());
- auto* instance = GetInstance();
- if (instance == nullptr)
- return false;
-
- if (!instance->IsETWExportEnabled())
- return false;
-
- CStringTokenizer category_group_tokens(category_group_name.begin(),
- category_group_name.end(), ",");
- while (category_group_tokens.GetNext()) {
- StringPiece category_group_token = category_group_tokens.token_piece();
- if (instance->IsCategoryEnabled(category_group_token)) {
- return true;
- }
- }
- return false;
-}
-
-bool TraceEventETWExport::UpdateEnabledCategories() {
- if (etw_match_any_keyword_ == CHROME_Context.MatchAnyKeyword)
- return false;
-
- // If the keyword has changed, update each category.
- // Chrome_Context.MatchAnyKeyword is set by UIforETW (or other ETW trace
- // recording tools) using the ETW infrastructure. This value will be set in
- // all Chrome processes that have registered their ETW provider.
- etw_match_any_keyword_ = CHROME_Context.MatchAnyKeyword;
- for (size_t i = 0; i < ARRAYSIZE(kFilteredEventGroupNames); i++) {
- if (etw_match_any_keyword_ & (1ULL << i)) {
- categories_status_[kFilteredEventGroupNames[i]] = true;
- } else {
- categories_status_[kFilteredEventGroupNames[i]] = false;
- }
- }
-
- // Also update the two default categories.
- if (etw_match_any_keyword_ & kOtherEventsKeywordBit) {
- categories_status_[kOtherEventsGroupName] = true;
- } else {
- categories_status_[kOtherEventsGroupName] = false;
- }
- if (etw_match_any_keyword_ & kDisabledOtherEventsKeywordBit) {
- categories_status_[kDisabledOtherEventsGroupName] = true;
- } else {
- categories_status_[kDisabledOtherEventsGroupName] = false;
- }
-
- DCHECK_EQ(kNumberOfCategories, categories_status_.size());
-
- // Update the categories in TraceLog.
- TraceLog::GetInstance()->UpdateETWCategoryGroupEnabledFlags();
-
- return true;
-}
-
-bool TraceEventETWExport::IsCategoryEnabled(StringPiece category_name) const {
- DCHECK_EQ(kNumberOfCategories, categories_status_.size());
- // Try to find the category and return its status if found
- auto it = categories_status_.find(category_name);
- if (it != categories_status_.end())
- return it->second;
-
- // Otherwise return the corresponding default status by first checking if the
- // category is disabled by default.
- if (category_name.starts_with("disabled-by-default")) {
- DCHECK(categories_status_.find(kDisabledOtherEventsGroupName) !=
- categories_status_.end());
- return categories_status_.find(kDisabledOtherEventsGroupName)->second;
- } else {
- DCHECK(categories_status_.find(kOtherEventsGroupName) !=
- categories_status_.end());
- return categories_status_.find(kOtherEventsGroupName)->second;
- }
-}
-
-// static
-void TraceEventETWExport::UpdateETWKeyword() {
- if (!IsETWExportEnabled())
- return;
- auto* instance = GetInstance();
- DCHECK(instance);
- instance->UpdateEnabledCategories();
-}
-} // namespace trace_event
-} // namespace base
diff --git a/base/trace_event/trace_event_etw_export_win.h b/base/trace_event/trace_event_etw_export_win.h
deleted file mode 100644
index 8a85b22..0000000
--- a/base/trace_event/trace_event_etw_export_win.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2015 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.
-
-// This file contains the Windows-specific exporting to ETW.
-#ifndef BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
-#define BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
-
-#include <stdint.h>
-
-#include <map>
-
-#include "base/base_export.h"
-#include "base/macros.h"
-#include "base/strings/string_piece.h"
-#include "base/trace_event/trace_event_impl.h"
-
-namespace base {
-
-template <typename Type>
-struct StaticMemorySingletonTraits;
-
-namespace trace_event {
-
-class BASE_EXPORT TraceEventETWExport {
- public:
- ~TraceEventETWExport();
-
- // Retrieves the singleton.
- // Note that this may return NULL post-AtExit processing.
- static TraceEventETWExport* GetInstance();
-
- // Enables/disables exporting of events to ETW. If disabled,
- // AddEvent and AddCustomEvent will simply return when called.
- static void EnableETWExport();
- static void DisableETWExport();
-
- // Returns true if ETW is enabled. For now, this is true if the command line
- // flag is specified.
- static bool IsETWExportEnabled();
-
- // Exports an event to ETW. This is mainly used in
- // TraceLog::AddTraceEventWithThreadIdAndTimestamp to export internal events.
- static void AddEvent(
- char phase,
- const unsigned char* category_group_enabled,
- const char* name,
- unsigned long long id,
- int num_args,
- const char* const* arg_names,
- const unsigned char* arg_types,
- const unsigned long long* arg_values,
- const std::unique_ptr<ConvertableToTraceFormat>* convertable_values);
-
- // Exports an ETW event that marks the end of a complete event.
- static void AddCompleteEndEvent(const char* name);
-
- // Returns true if any category in the group is enabled.
- static bool IsCategoryGroupEnabled(StringPiece category_group_name);
-
- private:
- // Ensure only the provider can construct us.
- friend struct StaticMemorySingletonTraits<TraceEventETWExport>;
- // To have access to UpdateKeyword().
- class ETWKeywordUpdateThread;
- TraceEventETWExport();
-
- // Updates the list of enabled categories by consulting the ETW keyword.
- // Returns true if there was a change, false otherwise.
- bool UpdateEnabledCategories();
-
- // Returns true if the category is enabled.
- bool IsCategoryEnabled(StringPiece category_name) const;
-
- // Called back by the update thread to check for potential changes to the
- // keyword.
- static void UpdateETWKeyword();
-
- // True if ETW is enabled. Allows hiding the exporting behind a flag.
- bool etw_export_enabled_;
-
- // Maps category names to their status (enabled/disabled).
- std::map<StringPiece, bool> categories_status_;
-
- // Local copy of the ETW keyword.
- uint64_t etw_match_any_keyword_;
-
- // Background thread that monitors changes to the ETW keyword and updates
- // the enabled categories when a change occurs.
- std::unique_ptr<ETWKeywordUpdateThread> keyword_update_thread_;
- PlatformThreadHandle keyword_update_thread_handle_;
-
- DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport);
-};
-
-} // namespace trace_event
-} // namespace base
-
-#endif // BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc
index 0012c09..f608261 100644
--- a/base/trace_event/trace_log.cc
+++ b/base/trace_event/trace_log.cc
@@ -45,10 +45,6 @@
#include "base/trace_event/trace_event.h"
#include "build_config.h"
-#if defined(OS_WIN)
-#include "base/trace_event/trace_event_etw_export_win.h"
-#endif
-
#if defined(OS_ANDROID)
// The linker assigns the virtual address of the start of current library to
// this symbol.
@@ -483,13 +479,6 @@
state_flags |= TraceCategory::ENABLED_FOR_RECORDING;
}
-#if defined(OS_WIN)
- if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled(
- category->name())) {
- state_flags |= TraceCategory::ENABLED_FOR_ETW_EXPORT;
- }
-#endif
-
uint32_t enabled_filters_bitmap = 0;
int index = 0;
for (const auto& event_filter : enabled_event_filters_) {
@@ -1243,15 +1232,6 @@
}
}
-#if defined(OS_WIN)
- // This is done sooner rather than later, to avoid creating the event and
- // acquiring the lock, which is not needed for ETW as it's already threadsafe.
- if (*category_group_enabled & TraceCategory::ENABLED_FOR_ETW_EXPORT)
- TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id,
- num_args, arg_names, arg_types, arg_values,
- convertable_values);
-#endif // OS_WIN
-
AddTraceEventOverrideCallback trace_event_override =
reinterpret_cast<AddTraceEventOverrideCallback>(
subtle::NoBarrier_Load(&trace_event_override_));
@@ -1452,12 +1432,6 @@
return;
AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_);
-#if defined(OS_WIN)
- // Generate an ETW event that marks the end of a complete event.
- if (category_group_enabled_local & TraceCategory::ENABLED_FOR_ETW_EXPORT)
- TraceEventETWExport::AddCompleteEndEvent(name);
-#endif // OS_WIN
-
std::string console_message;
if (category_group_enabled_local & TraceCategory::ENABLED_FOR_RECORDING) {
AddTraceEventOverrideCallback trace_event_override =
@@ -1702,21 +1676,6 @@
kTraceEventVectorBufferChunks);
}
-#if defined(OS_WIN)
-void TraceLog::UpdateETWCategoryGroupEnabledFlags() {
- // Go through each category and set/clear the ETW bit depending on whether the
- // category is enabled.
- for (TraceCategory& category : CategoryRegistry::GetAllCategories()) {
- if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled(
- category.name())) {
- category.set_state_flag(TraceCategory::ENABLED_FOR_ETW_EXPORT);
- } else {
- category.clear_state_flag(TraceCategory::ENABLED_FOR_ETW_EXPORT);
- }
- }
-}
-#endif // defined(OS_WIN)
-
void TraceLog::SetTraceBufferForTesting(
std::unique_ptr<TraceBuffer> trace_buffer) {
AutoLock lock(lock_);
diff --git a/base/trace_event/trace_log.h b/base/trace_event/trace_log.h
index 56df18d..e480323 100644
--- a/base/trace_event/trace_log.h
+++ b/base/trace_event/trace_log.h
@@ -343,13 +343,6 @@
// may not handle the flush request in time causing lost of unflushed events.
void SetCurrentThreadBlocksMessageLoop();
-#if defined(OS_WIN)
- // This function is called by the ETW exporting module whenever the ETW
- // keyword (flags) changes. This keyword indicates which categories should be
- // exported, so whenever it changes, we adjust accordingly.
- void UpdateETWCategoryGroupEnabledFlags();
-#endif
-
// Replaces |logged_events_| with a new TraceBuffer for testing.
void SetTraceBufferForTesting(std::unique_ptr<TraceBuffer> trace_buffer);
diff --git a/base/win/scoped_handle_verifier.cc b/base/win/scoped_handle_verifier.cc
index 6a73677..930d147 100644
--- a/base/win/scoped_handle_verifier.cc
+++ b/base/win/scoped_handle_verifier.cc
@@ -12,7 +12,6 @@
#include "base/debug/alias.h"
#include "base/debug/stack_trace.h"
#include "base/synchronization/lock_impl.h"
-#include "base/win/base_win_buildflags.h"
#include "base/win/current_module.h"
extern "C" {
diff --git a/base/win/scoped_winrt_initializer.cc b/base/win/scoped_winrt_initializer.cc
deleted file mode 100644
index e05679a..0000000
--- a/base/win/scoped_winrt_initializer.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2017 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.
-
-#include "base/win/scoped_winrt_initializer.h"
-
-#include "base/logging.h"
-#include "base/win/com_init_util.h"
-#include "base/win/core_winrt_util.h"
-#include "base/win/windows_version.h"
-
-namespace base {
-namespace win {
-
-ScopedWinrtInitializer::ScopedWinrtInitializer()
- : hr_(base::win::RoInitialize(RO_INIT_MULTITHREADED)) {
- DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- DCHECK_GE(GetVersion(), VERSION_WIN8);
-#if DCHECK_IS_ON()
- if (SUCCEEDED(hr_))
- AssertComApartmentType(ComApartmentType::MTA);
- else
- DCHECK_NE(RPC_E_CHANGED_MODE, hr_) << "Invalid COM thread model change";
-#endif
-}
-
-ScopedWinrtInitializer::~ScopedWinrtInitializer() {
- DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- if (SUCCEEDED(hr_))
- base::win::RoUninitialize();
-}
-
-bool ScopedWinrtInitializer::Succeeded() const {
- return SUCCEEDED(hr_);
-}
-
-} // namespace win
-} // namespace base
diff --git a/base/win/scoped_winrt_initializer.h b/base/win/scoped_winrt_initializer.h
deleted file mode 100644
index 7c76515..0000000
--- a/base/win/scoped_winrt_initializer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2017 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 BASE_WIN_SCOPED_WINRT_INITIALIZER_H_
-#define BASE_WIN_SCOPED_WINRT_INITIALIZER_H_
-
-#include <objbase.h>
-
-#include "base/base_export.h"
-#include "base/threading/thread_checker.h"
-#include "base/win/scoped_windows_thread_environment.h"
-
-namespace base {
-namespace win {
-
-// Initializes the Windows Runtime in the constructor and uninitalizes the
-// Windows Runtime in the destructor. As a side effect, COM is also initialized
-// as an MTA in the constructor and correspondingly uninitialized in the
-// destructor.
-//
-// Generally, you should only use this on Windows 8 or above. It is redundant
-// to use ScopedComInitializer in conjunction with ScopedWinrtInitializer.
-//
-// WARNING: This should only be used once per thread, ideally scoped to a
-// similar lifetime as the thread itself. You should not be using this in random
-// utility functions that make Windows Runtime calls -- instead ensure these
-// functions are running on a Windows Runtime supporting thread!
-class BASE_EXPORT ScopedWinrtInitializer
- : public ScopedWindowsThreadEnvironment {
- public:
- ScopedWinrtInitializer();
- ~ScopedWinrtInitializer() override;
-
- // ScopedWindowsThreadEnvironment:
- bool Succeeded() const override;
-
- private:
- const HRESULT hr_;
- THREAD_CHECKER(thread_checker_);
-
- DISALLOW_COPY_AND_ASSIGN(ScopedWinrtInitializer);
-};
-
-} // namespace win
-} // namespace base
-
-#endif // BASE_WIN_SCOPED_WINRT_INITIALIZER_H_
diff --git a/build/build_win.ninja.template b/build/build_win.ninja.template
index f5f8b65..3edfb6a 100644
--- a/build/build_win.ninja.template
+++ b/build/build_win.ninja.template
@@ -1,27 +1,25 @@
-arch = environment.x64
-
rule cc
- command = ninja -t msvc -e $arch -- $cc /nologo /showIncludes /FC @${out}.rsp /c ${in} /Fo${out}
+ command = ninja -t msvc -- $cc /nologo /showIncludes /FC @${out}.rsp /c ${in} /Fo${out}
description = CC ${out}
rspfile = ${out}.rsp
rspfile_content = ${defines} ${includes} ${cflags} ${cflags_c}
deps = msvc
rule cxx
- command = ninja -t msvc -e $arch -- $cxx /nologo /showIncludes /FC @${out}.rsp /c ${in} /Fo${out}
+ command = ninja -t msvc -- $cxx /nologo /showIncludes /FC @${out}.rsp /c ${in} /Fo${out}
description = CXX ${out}
rspfile = ${out}.rsp
rspfile_content = ${defines} ${includes} ${cflags} ${cflags_cc}
deps = msvc
rule alink_thin
- command = ninja -t msvc -e $arch -- $ar /nologo /ignore:4221 /OUT:${out} @${out}.rsp
+ command = ninja -t msvc -- $ar /nologo /ignore:4221 /OUT:${out} @${out}.rsp
description = LIB ${out}
rspfile = ${out}.rsp
- rspfile_content = ${in_newline}
+ rspfile_content = ${in_newline} ${libflags}
rule link
- command = ninja -t msvc -e $arch -- $ld /nologo /OUT:${out} /PDB:${out}.pdb @${out}.rsp
+ command = ninja -t msvc -- $ld /nologo /OUT:${out} /PDB:${out}.pdb @${out}.rsp
description = LINK ${out}
rspfile = ${out}.rsp
rspfile_content = ${in_newline} ${libs} ${solibs} ${ldflags}
diff --git a/build/gen.py b/build/gen.py
index 6d551eb..6c73d4e 100755
--- a/build/gen.py
+++ b/build/gen.py
@@ -47,8 +47,8 @@
def write_generic_ninja(path, static_libraries, executables,
- cc, cxx, ar, ld,
- cflags=[], cflags_cc=[], ldflags=[],
+ cc, cxx, ar, ld, options,
+ cflags=[], cflags_cc=[], ldflags=[], libflags=[],
include_dirs=[], solibs=[]):
ninja_header_lines = [
'cc = ' + cc,
@@ -57,7 +57,8 @@
'ld = ' + ld,
'',
'rule regen',
- ' command = %s ../build/gen.py' % sys.executable,
+ ' command = %s ../build/gen.py%s' % (
+ sys.executable, ' -d' if options.debug else ''),
' description = Regenerating ninja files',
'',
'build build.ninja: regen',
@@ -116,6 +117,8 @@
ninja_lines.append('build %s: alink_thin %s' % (
library_to_a(library),
' '.join([src_to_obj(src_file) for src_file in settings['sources']])))
+ ninja_lines.append(' libflags = %s' % ' '.join(libflags))
+
for executable, settings in executables.iteritems():
for src_file in settings['sources']:
@@ -161,6 +164,7 @@
cflags = os.environ.get('CFLAGS', '').split()
cflags_cc = os.environ.get('CXXFLAGS', '').split()
ldflags = os.environ.get('LDFLAGS', '').split()
+ libflags = os.environ.get('LIBFLAGS', '').split()
include_dirs = [REPO_ROOT, os.path.join(REPO_ROOT, 'src')]
libs = []
@@ -191,24 +195,37 @@
elif is_win:
if not options.debug:
cflags.extend(['/Ox', '/DNDEBUG', '/GL'])
+ libflags.extend(['/LTCG'])
ldflags.extend(['/LTCG', '/OPT:REF', '/OPT:ICF'])
cflags.extend([
+ '/DNOMINMAX',
+ '/DUNICODE',
+ '/DWIN32_LEAN_AND_MEAN',
+ '/DWINVER=0x0A00',
+ '/D_CRT_SECURE_NO_DEPRECATE',
+ '/D_SCL_SECURE_NO_DEPRECATE',
+ '/D_UNICODE',
+ '/D_WIN32_WINNT=0x0A00',
'/FS',
'/Gy',
- '/W3', '/wd4244',
+ '/W4',
+ '/WX',
'/Zi',
- '/DWIN32_LEAN_AND_MEAN', '/DNOMINMAX',
- '/D_CRT_SECURE_NO_DEPRECATE', '/D_SCL_SECURE_NO_DEPRECATE',
- '/D_WIN32_WINNT=0x0A00', '/DWINVER=0x0A00',
- '/DUNICODE', '/D_UNICODE',
+ '/wd4099',
+ '/wd4100',
+ '/wd4127',
+ '/wd4244',
+ '/wd4267',
+ '/wd4838',
+ '/wd4996',
])
cflags_cc.extend([
'/GR-',
'/D_HAS_EXCEPTIONS=0',
])
- ldflags.extend(['/MACHINE:x64'])
+ ldflags.extend(['/DEBUG', '/MACHINE:x64'])
static_libraries = {
'base': {'sources': [
@@ -789,7 +806,6 @@
'base/threading/thread_local_storage_win.cc',
'base/time/time_win.cc',
'base/timer/hi_res_timer_manager_win.cc',
- 'base/trace_event/trace_event_etw_export_win.cc',
'base/win/core_winrt_util.cc',
'base/win/enum_variant.cc',
'base/win/event_trace_controller.cc',
@@ -809,7 +825,6 @@
'base/win/scoped_handle_verifier.cc',
'base/win/scoped_process_information.cc',
'base/win/scoped_variant.cc',
- 'base/win/scoped_winrt_initializer.cc',
'base/win/shortcut.cc',
'base/win/startup_information.cc',
'base/win/wait_chain.cc',
@@ -837,7 +852,8 @@
executables['gn_unittests']['libs'].extend(static_libraries.keys())
write_generic_ninja(path, static_libraries, executables, cc, cxx, ar, ld,
- cflags, cflags_cc, ldflags, include_dirs, libs)
+ options, cflags, cflags_cc, ldflags, libflags,
+ include_dirs, libs)
if __name__ == '__main__':
diff --git a/src/test/gn_test.cc b/src/test/gn_test.cc
index 4d16195..0763048 100644
--- a/src/test/gn_test.cc
+++ b/src/test/gn_test.cc
@@ -120,10 +120,13 @@
}
}
- int nactivetests = 0;
- for (int i = 0; i < ntests; i++)
- if ((tests[i].should_run = TestMatchesFilter(tests[i].name, test_filter)))
- ++nactivetests;
+ int num_active_tests = 0;
+ for (int i = 0; i < ntests; i++) {
+ tests[i].should_run = TestMatchesFilter(tests[i].name, test_filter);
+ if (tests[i].should_run) {
+ ++num_active_tests;
+ }
+ }
const char* prefix = "";
const char* suffix = "\n";
@@ -143,8 +146,8 @@
++tests_started;
testing::Test* test = tests[i].factory();
- printf("%s[%d/%d] %s%s", prefix, tests_started, nactivetests, tests[i].name,
- suffix);
+ printf("%s[%d/%d] %s%s", prefix, tests_started, num_active_tests,
+ tests[i].name, suffix);
test->SetUp();
test->Run();
test->TearDown();
diff --git a/tools/gn/input_conversion.cc b/tools/gn/input_conversion.cc
index a7abcf4..22d33ca 100644
--- a/tools/gn/input_conversion.cc
+++ b/tools/gn/input_conversion.cc
@@ -142,7 +142,7 @@
case base::Value::Type::DICTIONARY: {
std::unique_ptr<Scope> scope = std::make_unique<Scope>(settings);
for (const auto& it : value.DictItems()) {
- Value value =
+ Value parsed_value =
ParseJSONValue(settings, it.second, origin, input_file, err);
if (!IsIdentifier(it.first)) {
*err = Err(origin, "Invalid identifier \"" + it.first + "\".");
@@ -158,7 +158,7 @@
}
base::StringPiece key(&input_file->contents()[off + 1],
it.first.size());
- scope->SetValue(key, std::move(value), origin);
+ scope->SetValue(key, std::move(parsed_value), origin);
}
return Value(origin, std::move(scope));
}
@@ -166,8 +166,9 @@
Value result(origin, Value::LIST);
result.list_value().reserve(value.GetList().size());
for (const auto& val : value.GetList()) {
- Value value = ParseJSONValue(settings, val, origin, input_file, err);
- result.list_value().push_back(value);
+ Value parsed_value =
+ ParseJSONValue(settings, val, origin, input_file, err);
+ result.list_value().push_back(parsed_value);
}
return result;
}