Refactor tracing to pass around base::debug::TraceOptions to reduce spaghetti

Previously, the options for tracing were passed around with different ad hoc
systems. Strings in some places, base::debug::TraceOptions enum in others,
and a content::TraceOptions in yet another. There were two separate ad-hoc
string formats. Similar messes were present with category filters: sometimes
we passed strings, sometimes the CategoryFilter.

This patch though enormous looking simply consolidates all this ad-hockery
into base::debug::TraceOptions. It may look like the call sites have gotten
more verbose,
but the end result of this is a consistent understanding of TraceOptions.

There is one exception to this consolidation: devtools has to maintain its own
mapping of string->TraceOptions encoding. This is because DevTools makes
guarantees about backward compatibility: if base changes its mind about the
string form of a TraceOption, devtools needs to keep supporting the old form.

BUG=396081
TBR=cevans@chromium.org

Review URL: https://codereview.chromium.org/425593002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287348 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Disable TraceOptionsTest.TraceOptionsFromString

This test breaks on iOS Simulation.

Introduced by https://codereview.chromium.org/425593002

BUG=400382
TBR=nednguyen

Review URL: https://codereview.chromium.org/438043003

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287361 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Disable TraceOptionsTest.TraceOptionsFromString

This test breaks on iOS Simulation.

Introduced by https://codereview.chromium.org/425593002

BUG=400382
TBR=nednguyen

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287361

Review URL: https://codereview.chromium.org/438043003

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287362 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
base/allocator: Hardcode TCMalloc optimization level to 2 on Windows.

TCMalloc is very slow in debug mode. Testing this out on Linux demonstrates
clear wins, so I'm hopeful Windows will similarly improve. This change mostly
copies the same configuration from ffmpeg, which unifies the setting of the
optimization level variables in target_defaults.

BUG=388949

Review URL: https://codereview.chromium.org/437163006

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287454 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
GN: Add missing dep from //base:prefs_test_support on //testing/gtest.

gtest.h is included pref_store_observer_mock.cc and testing_pref_service.cc.
Found using 'gn check'.

Review URL: https://codereview.chromium.org/435983003

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287540 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Factored out duplicate code for formatting full test name

R=phajdan.jr@chromium.org

Review URL: https://codereview.chromium.org/418093004

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287628 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Reenable trace_event_unittest for windows

BUG=396403

Review URL: https://codereview.chromium.org/432473002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287690 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Make QPCValueToMicroseconds faster in case the value is less than 44 bits

If the QPC value is less than 44 bits, it is safe to multiply by a 20 bits
value (1000000) without risking overflow. This optimization reduces the
call time by half.

BUG=158234

Review URL: https://codereview.chromium.org/429743002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287704 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Refactor GN source expansions.

This is in preparation for using {{patterns}} in toolchain definitions. It makes them
more generic and usable for this, without actually implementing any new features or
changing behavior. The only external change should be that the $in variable is used for
actions instead of making a redundant new variable (used to be called $source).

It removes the FileTemplate class and explodes it into several files: the type list and
helpers (substitution_type), a single pattern (substitution_pattern), a list of patterns
(substitution_list), and a class of helper functions for processing templates in various
ways (substitution_writer).

Previously, the things needing substitutions (args, outputs, depfile) were stored as
strings and parsed in to FileTemplates as needed. This new method stores the
SubstitutionList/Pattern directly on the target. This allows it to issue parse errors
(previously such errors were ignored since errors weren't reportable when writing Ninja
files) and cleans up a lot of the code that uses it.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/429423002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287847 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This is an ordered set tailored to GN's (simple) needs.

This vector is now used to store all config lists. Previously the code did a bunch of work to uniquify configs at certain points (in target.cc) but direct_dependent_configs still ended up with lots of duplicates.

Before this patch the chrome/browser target has 41098 direct_dependent_configs, and after this patch it has 7. Apparently we were also spending a lot of time on these. Before this patch Windows wall clock time was 1031ms, and after this patch it's 831ms. Linux was 834ms before and 593ms after.

Also fix minor build issues in base I noticed while working on this.

R=viettrungluu@chromium.org

Review URL: https://codereview.chromium.org/26537002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@287865 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Take extra lock in base::WaitableEvent::WaitMany.

Currently WaitMany doesn't ensure that the corresponding |Signal| is done
when the WaitMany call is returned.
That is problematic when we share the event over threads and want to wait
for detaching it in order to delete it after that.

BUG=397435
R=agl@chromium.org

Review URL: https://codereview.chromium.org/419773002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288005 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Add RECORD_AS_MUCH_AS_POSSIBLE mode to TraceOptions.

With current implementation of devtool_tracing_handler, it doesn't do 
anything with invalid options and just use RECORD_UNTIL_FULL by default. So
the change to telemetry's tracing backend will not break backward
compatibility for browsers that don't support "record-as-much-as-possible" option.

However, this is a hacky way to maintain backward compatibility, and we 
should fix devtool_tracing_handler so it can respond with error message on
Tracing.start if there is options parsing error.

BUG=396081

Review URL: https://codereview.chromium.org/440903003

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288047 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Update manually triggered try jobs to use swarming for ChromeOS and Mac since they're switched by CQ already.

TBR=ben

Review URL: https://codereview.chromium.org/450583002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288050 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Remove wstring file path helpers from test_file_util.

These were only used by one test file, so I moved the implementation there. I
considered updating the test, but the way the test uses wstrings seems
reasonable.

R=rvargas@chromium.org, rvargas

Review URL: https://codereview.chromium.org/448763003

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288084 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Move StringToLowerASCII to base namespace

TBR=sky

Review URL: https://codereview.chromium.org/448853002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288085 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Remove file_util::ScopedFILE and use base version.

There is only one user of this class. The new implementation is in
base/files/scoped_file.h

R=viettrungluu@chromium.org

Review URL: https://codereview.chromium.org/444083004

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288087 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Follow-up for https://codereview.chromium.org/419323002/

operator delete apparently isn't throw() with msvs (at least in
_HAS_EXCEPTIONS=0 builds like ours). This fixes the two remaining
warnings in this file:

..\..\base\allocator/generic_allocators.cc(31,6) :  warning(clang): function previously declared with an implicit exception specification redeclared with an explicit exception specification [-Wimplicit-exception-spec-mismatch]
void operator delete(void* p) throw() {
     ^
E:\b\depot_tools\win_toolchain\vs2013_files\win8sdk\bin\..\..\VC\include\new(52,16) :  note(clang): previous declaration is here
void __CRTDECL operator delete(void *) _THROW0();
               ^
In file included from ..\..\base\allocator\allocator_shim.cc:334:
..\..\base\allocator/generic_allocators.cc(39,6) :  warning(clang): function previously declared with an implicit exception specification redeclared with an explicit exception specification [-Wimplicit-exception-spec-mismatch]
void operator delete[](void* p) throw() {
     ^
E:\b\depot_tools\win_toolchain\vs2013_files\win8sdk\bin\..\..\VC\include\crtdbg.h(1054,16) :  note(clang): previous declaration is here
void __CRTDECL operator delete[](void *);
               ^
2 warnings generated.

There also wasn't a std::nothrow overload for delete, so add that for
completeness while here. (For C++14, we might have to add sized
overloads too at some point.)

BUG=82385
NOTRY=true

Review URL: https://codereview.chromium.org/447513002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288129 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Add DACL and fix test for anonymous read-only memory

BUG=338538
R=rvargas@chromium.org,brettw@chromium.org
TBR=brettw@chromium.org

Review URL: https://codereview.chromium.org/444323005

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288152 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Move the rest of test_file_util to base namespace.

R=rvargas@chromium.org

Review URL: https://codereview.chromium.org/444163003

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288158 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Move file_util_icu to base::i18n namespace

TBR=sky

Review URL: https://codereview.chromium.org/447403002

git-svn-id: http://src.chromium.org/svn/trunk/src/base@288170 4ff67af0-8c30-449e-8e8b-ad334ec8d88c