Merge branch 'chromium_upstream'
diff --git a/AUTHORS b/AUTHORS
index fd401bb..14b2e43 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -210,6 +210,7 @@
Hyunjune Kim <hyunjune.kim@samsung.com>
Hyunki Baik <hyunki.baik@samsung.com>
Hyungwook Lee <withlhw@gmail.com>
+Ian Cullinan <cullinan@amazon.com>
Ian Scott <ian.scott@arteris.com>
Ibrar Ahmed <ibrar.ahmad@gmail.com>
Ion Rosca <rosca@adobe.com>
@@ -479,6 +480,7 @@
Seshadri Mahalingam <seshadri.mahalingam@gmail.com>
Sevan Janiyan <venture37@geeklan.co.uk>
ShankarGanesh K <blr.bmlab@gmail.com>
+Shanmuga Pandi M <shanmuga.m@samsung.com>
Sherry Mou <wenjinm@amazon.com>
Shez Baig <sbaig1@bloomberg.net>
Shiliu Wang <aofdwsl@gmail.com>
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 9c24045..bc544f4 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -216,6 +216,8 @@
"files/file_posix.cc",
"files/file_proxy.cc",
"files/file_proxy.h",
+ "files/file_tracing.cc",
+ "files/file_tracing.h",
"files/file_util.cc",
"files/file_util.h",
"files/file_util_android.cc",
diff --git a/base/android/java/src/org/chromium/base/PathUtils.java b/base/android/java/src/org/chromium/base/PathUtils.java
index 0b3ed20..e46fc30 100644
--- a/base/android/java/src/org/chromium/base/PathUtils.java
+++ b/base/android/java/src/org/chromium/base/PathUtils.java
@@ -47,7 +47,7 @@
}
return paths;
}
- }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, suffix);
+ }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, suffix);
}
/**
diff --git a/base/base.gypi b/base/base.gypi
index cefc863..d1ab7b3 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -209,6 +209,8 @@
'files/file_posix.cc',
'files/file_proxy.cc',
'files/file_proxy.h',
+ 'files/file_tracing.cc',
+ 'files/file_tracing.h',
'files/file_util.cc',
'files/file_util.h',
'files/file_util_android.cc',
diff --git a/base/files/file.cc b/base/files/file.cc
index 8030bf1..58f80c5 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -4,6 +4,7 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
+#include "base/files/file_tracing.h"
#include "base/metrics/histogram.h"
#include "base/timer/elapsed_timer.h"
@@ -25,11 +26,11 @@
}
#if !defined(OS_NACL)
-File::File(const FilePath& name, uint32 flags)
+File::File(const FilePath& path, uint32 flags)
: error_details_(FILE_OK),
created_(false),
async_(false) {
- Initialize(name, flags);
+ Initialize(path, flags);
}
#endif
@@ -51,6 +52,7 @@
File::File(RValue other)
: file_(other.object->TakePlatformFile()),
+ path_(other.object->path_),
error_details_(other.object->error_details()),
created_(other.object->created()),
async_(other.object->async_) {
@@ -65,6 +67,7 @@
if (this != other.object) {
Close();
SetPlatformFile(other.object->TakePlatformFile());
+ path_ = other.object->path_;
error_details_ = other.object->error_details();
created_ = other.object->created();
async_ = other.object->async_;
@@ -73,12 +76,14 @@
}
#if !defined(OS_NACL)
-void File::Initialize(const FilePath& name, uint32 flags) {
- if (name.ReferencesParent()) {
+void File::Initialize(const FilePath& path, uint32 flags) {
+ if (path.ReferencesParent()) {
error_details_ = FILE_ERROR_ACCESS_DENIED;
return;
}
- DoInitialize(name, flags);
+ path_ = path;
+ SCOPED_FILE_TRACE("Initialize");
+ DoInitialize(flags);
}
#endif
@@ -128,6 +133,7 @@
bool File::Flush() {
ElapsedTimer timer;
+ SCOPED_FILE_TRACE("Flush");
bool return_value = DoFlush();
UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed());
return return_value;
diff --git a/base/files/file.h b/base/files/file.h
index 89077b4..b21b159 100644
--- a/base/files/file.h
+++ b/base/files/file.h
@@ -18,6 +18,8 @@
#include "base/base_export.h"
#include "base/basictypes.h"
+#include "base/files/file_path.h"
+#include "base/files/file_tracing.h"
#include "base/files/scoped_file.h"
#include "base/gtest_prod_util.h"
#include "base/move.h"
@@ -31,8 +33,6 @@
namespace base {
-class FilePath;
-
#if defined(OS_WIN)
typedef HANDLE PlatformFile;
#elif defined(OS_POSIX)
@@ -162,8 +162,8 @@
File();
// Creates or opens the given file. This will fail with 'access denied' if the
- // |name| contains path traversal ('..') components.
- File(const FilePath& name, uint32 flags);
+ // |path| contains path traversal ('..') components.
+ File(const FilePath& path, uint32 flags);
// Takes ownership of |platform_file|.
explicit File(PlatformFile platform_file);
@@ -180,7 +180,7 @@
File& operator=(RValue other);
// Creates or opens the given file.
- void Initialize(const FilePath& name, uint32 flags);
+ void Initialize(const FilePath& path, uint32 flags);
bool IsValid() const;
@@ -191,7 +191,7 @@
// Returns the OS result of opening this file. Note that the way to verify
// the success of the operation is to use IsValid(), not this method:
- // File file(name, flags);
+ // File file(path, flags);
// if (!file.IsValid())
// return;
Error error_details() const { return error_details_; }
@@ -305,6 +305,8 @@
private:
FRIEND_TEST_ALL_PREFIXES(::FileTest, MemoryCorruption);
+ friend class FileTracing::ScopedTrace;
+
#if defined(OS_POSIX)
// Encloses a single ScopedFD, saving a cheap tamper resistent memory checksum
// alongside it. This checksum is validated at every access, allowing early
@@ -350,9 +352,9 @@
};
#endif
- // Creates or opens the given file. Only called if |name| has no traversal
- // ('..') components.
- void DoInitialize(const FilePath& name, uint32 flags);
+ // Creates or opens the given file. Only called if |path_| has no
+ // traversal ('..') components.
+ void DoInitialize(uint32 flags);
// TODO(tnagel): Reintegrate into Flush() once histogram isn't needed anymore,
// cf. issue 473337.
@@ -366,6 +368,12 @@
MemoryCheckingScopedFD file_;
#endif
+ // Path that |Initialize()| was called with. Only set if safe (i.e. no '..').
+ FilePath path_;
+
+ // Object tied to the lifetime of |this| that enables/disables tracing.
+ FileTracing::ScopedEnabler trace_enabler_;
+
Error error_details_;
bool created_;
bool async_;
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index 4c79057..bb49d2d 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -9,7 +9,6 @@
#include <sys/stat.h>
#include <unistd.h>
-#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/sparse_histogram.h"
#include "base/posix/eintr_wrapper.h"
@@ -173,6 +172,7 @@
if (!IsValid())
return;
+ SCOPED_FILE_TRACE("Close");
ThreadRestrictions::AssertIOAllowed();
file_.reset();
}
@@ -181,6 +181,8 @@
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+ SCOPED_FILE_TRACE_WITH_SIZE("Seek", offset);
+
#if defined(OS_ANDROID)
COMPILE_ASSERT(sizeof(int64) == sizeof(off64_t), off64_t_64_bit);
return lseek64(file_.get(), static_cast<off64_t>(offset),
@@ -198,6 +200,8 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("Read", size);
+
int bytes_read = 0;
int rv;
do {
@@ -218,6 +222,8 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("ReadAtCurrentPos", size);
+
int bytes_read = 0;
int rv;
do {
@@ -234,7 +240,7 @@
int File::ReadNoBestEffort(int64 offset, char* data, int size) {
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
-
+ SCOPED_FILE_TRACE_WITH_SIZE("ReadNoBestEffort", size);
return HANDLE_EINTR(pread(file_.get(), data, size, offset));
}
@@ -244,6 +250,7 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("ReadAtCurrentPosNoBestEffort", size);
return HANDLE_EINTR(read(file_.get(), data, size));
}
@@ -257,6 +264,8 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("Write", size);
+
int bytes_written = 0;
int rv;
do {
@@ -277,6 +286,8 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("WriteAtCurrentPos", size);
+
int bytes_written = 0;
int rv;
do {
@@ -297,12 +308,15 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("WriteAtCurrentPosNoBestEffort", size);
return HANDLE_EINTR(write(file_.get(), data, size));
}
int64 File::GetLength() {
DCHECK(IsValid());
+ SCOPED_FILE_TRACE("GetLength");
+
stat_wrapper_t file_info;
if (CallFstat(file_.get(), &file_info))
return false;
@@ -313,6 +327,8 @@
bool File::SetLength(int64 length) {
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+
+ SCOPED_FILE_TRACE_WITH_SIZE("SetLength", length);
return !CallFtruncate(file_.get(), length);
}
@@ -320,6 +336,8 @@
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+ SCOPED_FILE_TRACE("SetTimes");
+
timeval times[2];
times[0] = last_access_time.ToTimeVal();
times[1] = last_modified_time.ToTimeVal();
@@ -330,6 +348,8 @@
bool File::GetInfo(Info* info) {
DCHECK(IsValid());
+ SCOPED_FILE_TRACE("GetInfo");
+
stat_wrapper_t file_info;
if (CallFstat(file_.get(), &file_info))
return false;
@@ -339,10 +359,12 @@
}
File::Error File::Lock() {
+ SCOPED_FILE_TRACE("Lock");
return CallFctnlFlock(file_.get(), true);
}
File::Error File::Unlock() {
+ SCOPED_FILE_TRACE("Unlock");
return CallFctnlFlock(file_.get(), false);
}
@@ -350,6 +372,8 @@
if (!IsValid())
return File();
+ SCOPED_FILE_TRACE("Duplicate");
+
PlatformFile other_fd = dup(GetPlatformFile());
if (other_fd == -1)
return File(OSErrorToFileError(errno));
@@ -442,7 +466,7 @@
// NaCl doesn't implement system calls to open files directly.
#if !defined(OS_NACL)
// TODO(erikkay): does it make sense to support FLAG_EXCLUSIVE_* here?
-void File::DoInitialize(const FilePath& name, uint32 flags) {
+void File::DoInitialize(uint32 flags) {
ThreadRestrictions::AssertIOAllowed();
DCHECK(!IsValid());
@@ -497,7 +521,7 @@
mode |= S_IRGRP | S_IROTH;
#endif
- int descriptor = HANDLE_EINTR(open(name.value().c_str(), open_flags, mode));
+ int descriptor = HANDLE_EINTR(open(path_.value().c_str(), open_flags, mode));
if (flags & FLAG_OPEN_ALWAYS) {
if (descriptor < 0) {
@@ -505,7 +529,7 @@
if (flags & FLAG_EXCLUSIVE_READ || flags & FLAG_EXCLUSIVE_WRITE)
open_flags |= O_EXCL; // together with O_CREAT implies O_NOFOLLOW
- descriptor = HANDLE_EINTR(open(name.value().c_str(), open_flags, mode));
+ descriptor = HANDLE_EINTR(open(path_.value().c_str(), open_flags, mode));
if (descriptor >= 0)
created_ = true;
}
@@ -520,7 +544,7 @@
created_ = true;
if (flags & FLAG_DELETE_ON_CLOSE)
- unlink(name.value().c_str());
+ unlink(path_.value().c_str());
async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC);
error_details_ = FILE_OK;
@@ -531,6 +555,7 @@
bool File::DoFlush() {
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+
#if defined(OS_NACL)
NOTIMPLEMENTED(); // NaCl doesn't implement fsync.
return true;
diff --git a/base/files/file_win.cc b/base/files/file_win.cc
index 200ea29..9792852 100644
--- a/base/files/file_win.cc
+++ b/base/files/file_win.cc
@@ -6,7 +6,6 @@
#include <io.h>
-#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/sparse_histogram.h"
#include "base/threading/thread_restrictions.h"
@@ -31,16 +30,20 @@
}
void File::Close() {
- if (file_.IsValid()) {
- ThreadRestrictions::AssertIOAllowed();
- file_.Close();
- }
+ if (!file_.IsValid())
+ return;
+
+ ThreadRestrictions::AssertIOAllowed();
+ SCOPED_FILE_TRACE("Close");
+ file_.Close();
}
int64 File::Seek(Whence whence, int64 offset) {
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+ SCOPED_FILE_TRACE_WITH_SIZE("Seek", offset);
+
LARGE_INTEGER distance, res;
distance.QuadPart = offset;
DWORD move_method = static_cast<DWORD>(whence);
@@ -56,6 +59,8 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("Read", size);
+
LARGE_INTEGER offset_li;
offset_li.QuadPart = offset;
@@ -79,6 +84,8 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("ReadAtCurrentPos", size);
+
DWORD bytes_read;
if (::ReadFile(file_.Get(), data, size, &bytes_read, NULL))
return bytes_read;
@@ -89,10 +96,12 @@
}
int File::ReadNoBestEffort(int64 offset, char* data, int size) {
+ // TODO(dbeam): trace this separately?
return Read(offset, data, size);
}
int File::ReadAtCurrentPosNoBestEffort(char* data, int size) {
+ // TODO(dbeam): trace this separately?
return ReadAtCurrentPos(data, size);
}
@@ -101,6 +110,8 @@
DCHECK(IsValid());
DCHECK(!async_);
+ SCOPED_FILE_TRACE_WITH_SIZE("Write", size);
+
LARGE_INTEGER offset_li;
offset_li.QuadPart = offset;
@@ -122,6 +133,8 @@
if (size < 0)
return -1;
+ SCOPED_FILE_TRACE_WITH_SIZE("WriteAtCurrentPos", size);
+
DWORD bytes_written;
if (::WriteFile(file_.Get(), data, size, &bytes_written, NULL))
return bytes_written;
@@ -136,6 +149,9 @@
int64 File::GetLength() {
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+
+ SCOPED_FILE_TRACE("GetLength");
+
LARGE_INTEGER size;
if (!::GetFileSizeEx(file_.Get(), &size))
return -1;
@@ -147,6 +163,8 @@
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+ SCOPED_FILE_TRACE_WITH_SIZE("SetLength", length);
+
// Get the current file pointer.
LARGE_INTEGER file_pointer;
LARGE_INTEGER zero;
@@ -176,6 +194,8 @@
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+ SCOPED_FILE_TRACE("SetTimes");
+
FILETIME last_access_filetime = last_access_time.ToFileTime();
FILETIME last_modified_filetime = last_modified_time.ToFileTime();
return (::SetFileTime(file_.Get(), NULL, &last_access_filetime,
@@ -186,6 +206,8 @@
ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
+ SCOPED_FILE_TRACE("GetInfo");
+
BY_HANDLE_FILE_INFORMATION file_info;
if (!GetFileInformationByHandle(file_.Get(), &file_info))
return false;
@@ -205,6 +227,9 @@
File::Error File::Lock() {
DCHECK(IsValid());
+
+ SCOPED_FILE_TRACE("Lock");
+
BOOL result = LockFile(file_.Get(), 0, 0, MAXDWORD, MAXDWORD);
if (!result)
return OSErrorToFileError(GetLastError());
@@ -213,6 +238,9 @@
File::Error File::Unlock() {
DCHECK(IsValid());
+
+ SCOPED_FILE_TRACE("Unlock");
+
BOOL result = UnlockFile(file_.Get(), 0, 0, MAXDWORD, MAXDWORD);
if (!result)
return OSErrorToFileError(GetLastError());
@@ -223,6 +251,8 @@
if (!IsValid())
return File();
+ SCOPED_FILE_TRACE("Duplicate");
+
HANDLE other_handle = nullptr;
if (!::DuplicateHandle(GetCurrentProcess(), // hSourceProcessHandle
@@ -278,7 +308,7 @@
}
}
-void File::DoInitialize(const FilePath& name, uint32 flags) {
+void File::DoInitialize(uint32 flags) {
ThreadRestrictions::AssertIOAllowed();
DCHECK(!IsValid());
@@ -346,7 +376,7 @@
if (flags & FLAG_BACKUP_SEMANTICS)
create_flags |= FILE_FLAG_BACKUP_SEMANTICS;
- file_.Set(CreateFile(name.value().c_str(), access, sharing, NULL,
+ file_.Set(CreateFile(path_.value().c_str(), access, sharing, NULL,
disposition, create_flags, NULL));
if (file_.IsValid()) {
diff --git a/base/format_macros.h b/base/format_macros.h
index 4d90c59..d58658d 100644
--- a/base/format_macros.h
+++ b/base/format_macros.h
@@ -23,19 +23,20 @@
#include "build/build_config.h"
-#if defined(OS_POSIX)
-
-#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
+#if defined(OS_POSIX) && (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && \
+ !defined(PRId64)
#error "inttypes.h has already been included before this header file, but "
#error "without __STDC_FORMAT_MACROS defined."
#endif
-#if !defined(__STDC_FORMAT_MACROS)
+#if defined(OS_POSIX) && !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
+#if defined(OS_POSIX)
+
// GCC will concatenate wide and narrow strings correctly, so nothing needs to
// be done here.
#define WidePRId64 PRId64
@@ -76,16 +77,8 @@
#else // OS_WIN
-#if !defined(PRId64)
-#define PRId64 "I64d"
-#endif
-
-#if !defined(PRIu64)
-#define PRIu64 "I64u"
-#endif
-
-#if !defined(PRIx64)
-#define PRIx64 "I64x"
+#if !defined(PRId64) || !defined(PRIu64) || !defined(PRIx64)
+#error "inttypes.h provided by win toolchain should define these."
#endif
#define WidePRId64 L"I64d"
diff --git a/base/json/json_writer_unittest.cc b/base/json/json_writer_unittest.cc
index ec60b5e..802876c 100644
--- a/base/json/json_writer_unittest.cc
+++ b/base/json/json_writer_unittest.cc
@@ -12,58 +12,49 @@
std::string output_js;
// Test null.
- Value* root = Value::CreateNullValue();
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ scoped_ptr<Value> root(Value::CreateNullValue());
+ EXPECT_TRUE(JSONWriter::Write(root.get(), &output_js));
EXPECT_EQ("null", output_js);
- delete root;
// Test empty dict.
- root = new DictionaryValue;
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ DictionaryValue dict;
+ EXPECT_TRUE(JSONWriter::Write(&dict, &output_js));
EXPECT_EQ("{}", output_js);
- delete root;
// Test empty list.
- root = new ListValue;
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ ListValue list;
+ EXPECT_TRUE(JSONWriter::Write(&list, &output_js));
EXPECT_EQ("[]", output_js);
- delete root;
// Test integer values.
- root = new FundamentalValue(42);
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ FundamentalValue int_value(42);
+ EXPECT_TRUE(JSONWriter::Write(&int_value, &output_js));
EXPECT_EQ("42", output_js);
- delete root;
// Test boolean values.
- root = new FundamentalValue(true);
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ FundamentalValue bool_value(true);
+ EXPECT_TRUE(JSONWriter::Write(&bool_value, &output_js));
EXPECT_EQ("true", output_js);
- delete root;
// Test Real values should always have a decimal or an 'e'.
- root = new FundamentalValue(1.0);
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ FundamentalValue double_value(1.0);
+ EXPECT_TRUE(JSONWriter::Write(&double_value, &output_js));
EXPECT_EQ("1.0", output_js);
- delete root;
// Test Real values in the the range (-1, 1) must have leading zeros
- root = new FundamentalValue(0.2);
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ FundamentalValue double_value2(0.2);
+ EXPECT_TRUE(JSONWriter::Write(&double_value2, &output_js));
EXPECT_EQ("0.2", output_js);
- delete root;
// Test Real values in the the range (-1, 1) must have leading zeros
- root = new FundamentalValue(-0.8);
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ FundamentalValue double_value3(-0.8);
+ EXPECT_TRUE(JSONWriter::Write(&double_value3, &output_js));
EXPECT_EQ("-0.8", output_js);
- delete root;
// Test String values.
- root = new StringValue("foo");
- EXPECT_TRUE(JSONWriter::Write(root, &output_js));
+ StringValue string_value("foo");
+ EXPECT_TRUE(JSONWriter::Write(&string_value, &output_js));
EXPECT_EQ("\"foo\"", output_js);
- delete root;
}
@@ -128,18 +119,17 @@
// Binary values should return errors unless suppressed via the
// OPTIONS_OMIT_BINARY_VALUES flag.
- Value* root = BinaryValue::CreateWithCopiedBuffer("asdf", 4);
- EXPECT_FALSE(JSONWriter::Write(root, &output_js));
+ scoped_ptr<Value> root(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
+ EXPECT_FALSE(JSONWriter::Write(root.get(), &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
- root, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
+ root.get(), JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
EXPECT_TRUE(output_js.empty());
- delete root;
ListValue binary_list;
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
- binary_list.Append(new FundamentalValue(5));
+ binary_list.Append(make_scoped_ptr(new FundamentalValue(5)));
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
- binary_list.Append(new FundamentalValue(2));
+ binary_list.Append(make_scoped_ptr(new FundamentalValue(2)));
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
EXPECT_FALSE(JSONWriter::Write(&binary_list, &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
diff --git a/base/test/trace_event_analyzer_unittest.cc b/base/test/trace_event_analyzer_unittest.cc
index 4bdb941..cf85fd0 100644
--- a/base/test/trace_event_analyzer_unittest.cc
+++ b/base/test/trace_event_analyzer_unittest.cc
@@ -225,7 +225,7 @@
scoped_ptr<TraceAnalyzer>
analyzer(TraceAnalyzer::Create(output_.json_output));
- ASSERT_TRUE(!!analyzer.get());
+ ASSERT_TRUE(analyzer);
analyzer->SetIgnoreMetadataEvents(true);
TraceEventVector found;
diff --git a/base/time/time.cc b/base/time/time.cc
index bf6c998..9834188 100644
--- a/base/time/time.cc
+++ b/base/time/time.cc
@@ -97,20 +97,21 @@
return delta_;
}
-int64 TimeDelta::SaturatedAdd(int64 value) const {
- CheckedNumeric<int64> rv(delta_);
+namespace time_internal {
+
+int64 SaturatedAdd(TimeDelta delta, int64 value) {
+ CheckedNumeric<int64> rv(delta.delta_);
rv += value;
return FromCheckedNumeric(rv);
}
-int64 TimeDelta::SaturatedSub(int64 value) const {
- CheckedNumeric<int64> rv(delta_);
+int64 SaturatedSub(TimeDelta delta, int64 value) {
+ CheckedNumeric<int64> rv(delta.delta_);
rv -= value;
return FromCheckedNumeric(rv);
}
-// static
-int64 TimeDelta::FromCheckedNumeric(const CheckedNumeric<int64> value) {
+int64 FromCheckedNumeric(const CheckedNumeric<int64> value) {
if (value.IsValid())
return value.ValueUnsafe();
@@ -124,6 +125,8 @@
return value.ValueOrDefault(limit);
}
+} // namespace time_internal
+
std::ostream& operator<<(std::ostream& os, TimeDelta time_delta) {
return os << time_delta.InSecondsF() << "s";
}
@@ -305,15 +308,12 @@
TimeDelta tick_interval) const {
// |interval_offset| is the offset from |this| to the next multiple of
// |tick_interval| after |tick_phase|, possibly negative if in the past.
- TimeDelta interval_offset = TimeDelta::FromInternalValue(
- (tick_phase - *this).ToInternalValue() % tick_interval.ToInternalValue());
+ TimeDelta interval_offset = (tick_phase - *this) % tick_interval;
// If |this| is exactly on the interval (i.e. offset==0), don't adjust.
// Otherwise, if |tick_phase| was in the past, adjust forward to the next
// tick after |this|.
- if (interval_offset.ToInternalValue() != 0 && tick_phase < *this) {
+ if (!interval_offset.is_zero() && tick_phase < *this)
interval_offset += tick_interval;
- }
-
return *this + interval_offset;
}
diff --git a/base/time/time.h b/base/time/time.h
index 5c8b89c..0a26778 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -57,8 +57,23 @@
namespace base {
-class Time;
-class TimeTicks;
+class TimeDelta;
+
+// The functions in the time_internal namespace are meant to be used only by the
+// time classes and functions. Please use the math operators defined in the
+// time classes instead.
+namespace time_internal {
+
+// Add or subtract |value| from a TimeDelta. The int64 argument and return value
+// are in terms of a microsecond timebase.
+BASE_EXPORT int64 SaturatedAdd(TimeDelta delta, int64 value);
+BASE_EXPORT int64 SaturatedSub(TimeDelta delta, int64 value);
+
+// Clamp |value| on overflow and underflow conditions. The int64 argument and
+// return value are in terms of a microsecond timebase.
+BASE_EXPORT int64 FromCheckedNumeric(const CheckedNumeric<int64> value);
+
+} // namespace time_internal
// TimeDelta ------------------------------------------------------------------
@@ -110,6 +125,11 @@
return TimeDelta((delta_ + mask) ^ mask);
}
+ // Returns true if the time delta is zero.
+ bool is_zero() const {
+ return delta_ == 0;
+ }
+
// Returns true if the time delta is the maximum time delta.
bool is_max() const {
return delta_ == std::numeric_limits<int64>::max();
@@ -141,19 +161,17 @@
// Computations with other deltas.
TimeDelta operator+(TimeDelta other) const {
- return TimeDelta(SaturatedAdd(other.delta_));
+ return TimeDelta(time_internal::SaturatedAdd(*this, other.delta_));
}
TimeDelta operator-(TimeDelta other) const {
- return TimeDelta(SaturatedSub(other.delta_));
+ return TimeDelta(time_internal::SaturatedSub(*this, other.delta_));
}
TimeDelta& operator+=(TimeDelta other) {
- delta_ = SaturatedAdd(other.delta_);
- return *this;
+ return *this = (*this + other);
}
TimeDelta& operator-=(TimeDelta other) {
- delta_ = SaturatedSub(other.delta_);
- return *this;
+ return *this = (*this - other);
}
TimeDelta operator-() const {
return TimeDelta(-delta_);
@@ -164,36 +182,29 @@
TimeDelta operator*(T a) const {
CheckedNumeric<int64> rv(delta_);
rv *= a;
- return TimeDelta(FromCheckedNumeric(rv));
+ return TimeDelta(time_internal::FromCheckedNumeric(rv));
}
template<typename T>
TimeDelta operator/(T a) const {
CheckedNumeric<int64> rv(delta_);
rv /= a;
- return TimeDelta(FromCheckedNumeric(rv));
+ return TimeDelta(time_internal::FromCheckedNumeric(rv));
}
template<typename T>
TimeDelta& operator*=(T a) {
- CheckedNumeric<int64> rv(delta_);
- rv *= a;
- delta_ = FromCheckedNumeric(rv);
- return *this;
+ return *this = (*this * a);
}
template<typename T>
TimeDelta& operator/=(T a) {
- CheckedNumeric<int64> rv(delta_);
- rv /= a;
- delta_ = FromCheckedNumeric(rv);
- return *this;
+ return *this = (*this / a);
}
int64 operator/(TimeDelta a) const {
return delta_ / a.delta_;
}
-
- // Defined below because it depends on the definition of the other classes.
- Time operator+(Time t) const;
- TimeTicks operator+(TimeTicks t) const;
+ TimeDelta operator%(TimeDelta a) const {
+ return TimeDelta(delta_ % a.delta_);
+ }
// Comparison operators.
bool operator==(TimeDelta other) const {
@@ -216,8 +227,8 @@
}
private:
- friend class Time;
- friend class TimeTicks;
+ friend int64 time_internal::SaturatedAdd(TimeDelta delta, int64 value);
+ friend int64 time_internal::SaturatedSub(TimeDelta delta, int64 value);
// Constructs a delta given the duration in microseconds. This is private
// to avoid confusion by callers with an integer constructor. Use
@@ -225,13 +236,6 @@
explicit TimeDelta(int64 delta_us) : delta_(delta_us) {
}
- // Add or subtract |value| from this delta.
- int64 SaturatedAdd(int64 value) const;
- int64 SaturatedSub(int64 value) const;
-
- // Clamp |value| on overflow and underflow conditions.
- static int64 FromCheckedNumeric(const CheckedNumeric<int64> value);
-
// Delta in microseconds.
int64 delta_;
};
@@ -244,10 +248,19 @@
// For logging use only.
BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeDelta time_delta);
-// Time -----------------------------------------------------------------------
+// Do not reference the time_internal::TimeBase template class directly. Please
+// use one of the time subclasses instead, and only reference the public
+// TimeBase members via those classes.
+namespace time_internal {
-// Represents a wall clock time in UTC.
-class BASE_EXPORT Time {
+// TimeBase--------------------------------------------------------------------
+
+// Provides value storage and comparison/math operations common to all time
+// classes. Each subclass provides for strong type-checking to ensure
+// semantically meaningful comparison/math of time values from the same clock
+// source or timeline.
+template<class TimeClass>
+class TimeBase {
public:
static const int64 kHoursPerDay = 24;
static const int64 kMillisecondsPerSecond = 1000;
@@ -264,6 +277,102 @@
static const int64 kNanosecondsPerSecond = kNanosecondsPerMicrosecond *
kMicrosecondsPerSecond;
+ // Returns true if this object has not been initialized.
+ //
+ // Warning: Be careful when writing code that performs math on time values,
+ // since it's possible to produce a valid "zero" result that should not be
+ // interpreted as a "null" value.
+ bool is_null() const {
+ return us_ == 0;
+ }
+
+ // Returns true if this object represents the maximum time.
+ bool is_max() const {
+ return us_ == std::numeric_limits<int64>::max();
+ }
+
+ // For serializing only. Use FromInternalValue() to reconstitute. Please don't
+ // use this and do arithmetic on it, as it is more error prone than using the
+ // provided operators.
+ int64 ToInternalValue() const {
+ return us_;
+ }
+
+ TimeClass& operator=(TimeClass other) {
+ us_ = other.us_;
+ return *(static_cast<TimeClass*>(this));
+ }
+
+ // Compute the difference between two times.
+ TimeDelta operator-(TimeClass other) const {
+ return TimeDelta::FromMicroseconds(us_ - other.us_);
+ }
+
+ // Return a new time modified by some delta.
+ TimeClass operator+(TimeDelta delta) const {
+ return TimeClass(time_internal::SaturatedAdd(delta, us_));
+ }
+ TimeClass operator-(TimeDelta delta) const {
+ return TimeClass(-time_internal::SaturatedSub(delta, us_));
+ }
+
+ // Modify by some time delta.
+ TimeClass& operator+=(TimeDelta delta) {
+ return static_cast<TimeClass&>(*this = (*this + delta));
+ }
+ TimeClass& operator-=(TimeDelta delta) {
+ return static_cast<TimeClass&>(*this = (*this - delta));
+ }
+
+ // Comparison operators
+ bool operator==(TimeClass other) const {
+ return us_ == other.us_;
+ }
+ bool operator!=(TimeClass other) const {
+ return us_ != other.us_;
+ }
+ bool operator<(TimeClass other) const {
+ return us_ < other.us_;
+ }
+ bool operator<=(TimeClass other) const {
+ return us_ <= other.us_;
+ }
+ bool operator>(TimeClass other) const {
+ return us_ > other.us_;
+ }
+ bool operator>=(TimeClass other) const {
+ return us_ >= other.us_;
+ }
+
+ // Converts an integer value representing TimeClass to a class. This is used
+ // when deserializing a |TimeClass| structure, using a value known to be
+ // compatible. It is not provided as a constructor because the integer type
+ // may be unclear from the perspective of a caller.
+ static TimeClass FromInternalValue(int64 us) {
+ return TimeClass(us);
+ }
+
+ protected:
+ explicit TimeBase(int64 us) : us_(us) {
+ }
+
+ // Time value in a microsecond timebase.
+ int64 us_;
+};
+
+} // namespace time_internal
+
+template<class TimeClass>
+inline TimeClass operator+(TimeDelta delta, TimeClass t) {
+ return t + delta;
+}
+
+// Time -----------------------------------------------------------------------
+
+// Represents a wall clock time in UTC. Values are not guaranteed to be
+// monotonically non-decreasing and are subject to large amounts of skew.
+class BASE_EXPORT Time : public time_internal::TimeBase<Time> {
+ public:
// The representation of Jan 1, 1970 UTC in microseconds since the
// platform-dependent epoch.
static const int64 kTimeTToMicrosecondsOffset;
@@ -303,17 +412,7 @@
};
// Contains the NULL time. Use Time::Now() to get the current time.
- Time() : us_(0) {
- }
-
- // Returns true if the time object has not been initialized.
- bool is_null() const {
- return us_ == 0;
- }
-
- // Returns true if the time object is the maximum time.
- bool is_max() const {
- return us_ == std::numeric_limits<int64>::max();
+ Time() : TimeBase(0) {
}
// Returns the time for epoch in Unix-like system (Jan 1, 1970).
@@ -412,14 +511,6 @@
return FromExploded(true, exploded);
}
- // Converts an integer value representing Time to a class. This is used
- // when deserializing a |Time| structure, using a value known to be
- // compatible. It is not provided as a constructor because the integer type
- // may be unclear from the perspective of a caller.
- static Time FromInternalValue(int64 us) {
- return Time(us);
- }
-
// Converts a string representation of time to a Time object.
// An example of a time string which is converted is as below:-
// "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified
@@ -435,13 +526,6 @@
return FromStringInternal(time_string, false, parsed_time);
}
- // For serializing, use FromInternalValue to reconstitute. Please don't use
- // this and do arithmetic on it, as it is more error prone than using the
- // provided operators.
- int64 ToInternalValue() const {
- return us_;
- }
-
// Fills the given exploded structure with either the local time or UTC from
// this time structure (containing UTC).
void UTCExplode(Exploded* exploded) const {
@@ -455,58 +539,10 @@
// midnight on that day.
Time LocalMidnight() const;
- Time& operator=(Time other) {
- us_ = other.us_;
- return *this;
- }
-
- // Compute the difference between two times.
- TimeDelta operator-(Time other) const {
- return TimeDelta(us_ - other.us_);
- }
-
- // Modify by some time delta.
- Time& operator+=(TimeDelta delta) {
- us_ = delta.SaturatedAdd(us_);
- return *this;
- }
- Time& operator-=(TimeDelta delta) {
- us_ = -delta.SaturatedSub(us_);
- return *this;
- }
-
- // Return a new time modified by some delta.
- Time operator+(TimeDelta delta) const {
- return Time(delta.SaturatedAdd(us_));
- }
- Time operator-(TimeDelta delta) const {
- return Time(-delta.SaturatedSub(us_));
- }
-
- // Comparison operators
- bool operator==(Time other) const {
- return us_ == other.us_;
- }
- bool operator!=(Time other) const {
- return us_ != other.us_;
- }
- bool operator<(Time other) const {
- return us_ < other.us_;
- }
- bool operator<=(Time other) const {
- return us_ <= other.us_;
- }
- bool operator>(Time other) const {
- return us_ > other.us_;
- }
- bool operator>=(Time other) const {
- return us_ >= other.us_;
- }
-
private:
- friend class TimeDelta;
+ friend class time_internal::TimeBase<Time>;
- explicit Time(int64 us) : us_(us) {
+ explicit Time(int64 us) : TimeBase(us) {
}
// Explodes the given time to either local time |is_local = true| or UTC
@@ -527,9 +563,6 @@
static bool FromStringInternal(const char* time_string,
bool is_local,
Time* parsed_time);
-
- // Time in microseconds in UTC.
- int64 us_;
};
// Inline the TimeDelta factory methods, for fast TimeDelta construction.
@@ -598,16 +631,13 @@
return TimeDelta(us);
}
-inline Time TimeDelta::operator+(Time t) const {
- return Time(SaturatedAdd(t.us_));
-}
-
// For logging use only.
BASE_EXPORT std::ostream& operator<<(std::ostream& os, Time time);
// TimeTicks ------------------------------------------------------------------
-class BASE_EXPORT TimeTicks {
+// Represents monotonically non-decreasing clock time.
+class BASE_EXPORT TimeTicks : public time_internal::TimeBase<TimeTicks> {
public:
// We define this even without OS_CHROMEOS for seccomp sandbox testing.
#if defined(OS_LINUX)
@@ -617,7 +647,7 @@
static const clockid_t kClockSystemTrace = 11;
#endif
- TimeTicks() : ticks_(0) {
+ TimeTicks() : TimeBase(0) {
}
// Platform-dependent tick count representing "right now." When
@@ -676,24 +706,6 @@
static TimeTicks FromQPCValue(LONGLONG qpc_value);
#endif
- // Returns true if this object has not been initialized.
- bool is_null() const {
- return ticks_ == 0;
- }
-
- // Returns true if the time delta is the maximum delta.
- bool is_max() const {
- return ticks_ == std::numeric_limits<int64>::max();
- }
-
- // Converts an integer value representing TimeTicks to a class. This is used
- // when deserializing a |TimeTicks| structure, using a value known to be
- // compatible. It is not provided as a constructor because the integer type
- // may be unclear from the perspective of a caller.
- static TimeTicks FromInternalValue(int64 ticks) {
- return TimeTicks(ticks);
- }
-
// Get the TimeTick value at the time of the UnixEpoch. This is useful when
// you need to relate the value of TimeTicks to a real time and date.
// Note: Upon first invocation, this function takes a snapshot of the realtime
@@ -702,86 +714,26 @@
// application runs.
static TimeTicks UnixEpoch();
- // Returns the internal numeric value of the TimeTicks object.
- // For serializing, use FromInternalValue to reconstitute.
- int64 ToInternalValue() const {
- return ticks_;
- }
-
// Returns |this| snapped to the next tick, given a |tick_phase| and
// repeating |tick_interval| in both directions. |this| may be before,
// after, or equal to the |tick_phase|.
TimeTicks SnappedToNextTick(TimeTicks tick_phase,
TimeDelta tick_interval) const;
- TimeTicks& operator=(TimeTicks other) {
- ticks_ = other.ticks_;
- return *this;
- }
-
- // Compute the difference between two times.
- TimeDelta operator-(TimeTicks other) const {
- return TimeDelta(ticks_ - other.ticks_);
- }
-
- // Modify by some time delta.
- TimeTicks& operator+=(TimeDelta delta) {
- ticks_ = delta.SaturatedAdd(ticks_);
- return *this;
- }
- TimeTicks& operator-=(TimeDelta delta) {
- ticks_ = -delta.SaturatedSub(ticks_);
- return *this;
- }
-
- // Return a new TimeTicks modified by some delta.
- TimeTicks operator+(TimeDelta delta) const {
- return TimeTicks(delta.SaturatedAdd(ticks_));
- }
- TimeTicks operator-(TimeDelta delta) const {
- return TimeTicks(-delta.SaturatedSub(ticks_));
- }
-
- // Comparison operators
- bool operator==(TimeTicks other) const {
- return ticks_ == other.ticks_;
- }
- bool operator!=(TimeTicks other) const {
- return ticks_ != other.ticks_;
- }
- bool operator<(TimeTicks other) const {
- return ticks_ < other.ticks_;
- }
- bool operator<=(TimeTicks other) const {
- return ticks_ <= other.ticks_;
- }
- bool operator>(TimeTicks other) const {
- return ticks_ > other.ticks_;
- }
- bool operator>=(TimeTicks other) const {
- return ticks_ >= other.ticks_;
- }
-
- protected:
- friend class TimeDelta;
-
- // Please use Now() to create a new object. This is for internal use
- // and testing. Ticks is in microseconds.
- explicit TimeTicks(int64 ticks) : ticks_(ticks) {
- }
-
- // Tick count in microseconds.
- int64 ticks_;
-
#if defined(OS_WIN)
+ protected:
typedef DWORD (*TickFunctionType)(void);
static TickFunctionType SetMockTickFunction(TickFunctionType ticker);
#endif
-};
-inline TimeTicks TimeDelta::operator+(TimeTicks t) const {
- return TimeTicks(SaturatedAdd(t.ticks_));
-}
+ private:
+ friend class time_internal::TimeBase<TimeTicks>;
+
+ // Please use Now() to create a new object. This is for internal use
+ // and testing.
+ explicit TimeTicks(int64 us) : TimeBase(us) {
+ }
+};
// For logging use only.
BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks);
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 6c12423..456782c 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -717,7 +717,7 @@
TEST(TimeTicks, SnappedToNextTickBasic) {
base::TimeTicks phase = base::TimeTicks::FromInternalValue(4000);
- base::TimeDelta interval = base::TimeDelta::FromInternalValue(1000);
+ base::TimeDelta interval = base::TimeDelta::FromMicroseconds(1000);
base::TimeTicks timestamp;
// Timestamp in previous interval.
@@ -760,7 +760,7 @@
// int(big_timestamp / interval) < 0, so this causes a crash if the number of
// intervals elapsed is attempted to be stored in an int.
base::TimeTicks phase = base::TimeTicks::FromInternalValue(0);
- base::TimeDelta interval = base::TimeDelta::FromInternalValue(4000);
+ base::TimeDelta interval = base::TimeDelta::FromMicroseconds(4000);
base::TimeTicks big_timestamp =
base::TimeTicks::FromInternalValue(8635916564000);
diff --git a/base/trace_event/trace_event.h b/base/trace_event/trace_event.h
index d4e8070..2c30b33 100644
--- a/base/trace_event/trace_event.h
+++ b/base/trace_event/trace_event.h
@@ -716,27 +716,43 @@
// NESTABLE_ASYNC event of that id. Corresponding warning messages for
// unmatched events will be shown in the analysis view.
-// Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with 2
-// associated arguments. If the category is not enabled, then this does nothing.
+// Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with
+// 0, 1 or 2 associated arguments. If the category is not enabled, then this
+// does nothing.
+#define TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_group, name, id) \
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
+ category_group, name, id, TRACE_EVENT_FLAG_NONE)
+#define TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
+ arg1_val) \
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
+ category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
#define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
arg1_val, arg2_name, arg2_val) \
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
arg2_name, arg2_val)
+// Records a single NESTABLE_ASYNC_END event called "name" immediately, with 0,
+// 1, or 2 associated arguments. If the category is not enabled, then this does
+// nothing.
+#define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
+ category_group, name, id, TRACE_EVENT_FLAG_NONE)
+#define TRACE_EVENT_NESTABLE_ASYNC_END1(category_group, name, id, arg1_name, \
+ arg1_val) \
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
+ category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
+#define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \
+ arg1_val, arg2_name, arg2_val) \
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
+ category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
+ arg2_name, arg2_val)
+
#define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2(category_group, name, \
id, arg1_name, arg1_val, arg2_name, arg2_val) \
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
category_group, name, id, \
TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, \
arg1_name, arg1_val, arg2_name, arg2_val)
-
-// Records a single NESTABLE_ASYNC_END event called "name" immediately, with 2
-// associated arguments. If the category is not enabled, then this does nothing.
-#define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \
- arg1_val, arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
- category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
#define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2(category_group, name, \
id, arg1_name, arg1_val, arg2_name, arg2_val) \
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc
index 17953e7..d032243 100644
--- a/base/trace_event/trace_event_unittest.cc
+++ b/base/trace_event/trace_event_unittest.cc
@@ -1527,7 +1527,7 @@
// See if this thread name is one of the threads we just created
for (int j = 0; j < kNumThreads; j++) {
- if(static_cast<int>(thread_ids[j]) != tmp_int)
+ if (static_cast<int>(thread_ids[j]) != tmp_int)
continue;
std::string expected_name = StringPrintf("Thread %d", j);
@@ -2214,7 +2214,7 @@
}
void TearDown() override {
TraceLog::GetInstance()->SetDisabled();
- ASSERT_TRUE(!!s_instance);
+ ASSERT_TRUE(s_instance);
s_instance = NULL;
TraceEventTestFixture::TearDown();
}
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 0d39d8b..b365a22 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -33,14 +33,14 @@
ASSERT_FALSE(
settings.GetList("global.toolbar.bookmarks", &toolbar_bookmarks));
- toolbar_bookmarks = new ListValue;
- settings.Set("global.toolbar.bookmarks", make_scoped_ptr(toolbar_bookmarks));
+ scoped_ptr<ListValue> new_toolbar_bookmarks(new ListValue);
+ settings.Set("global.toolbar.bookmarks", new_toolbar_bookmarks.Pass());
ASSERT_TRUE(settings.GetList("global.toolbar.bookmarks", &toolbar_bookmarks));
- DictionaryValue* new_bookmark = new DictionaryValue;
+ scoped_ptr<DictionaryValue> new_bookmark(new DictionaryValue);
new_bookmark->SetString("name", "Froogle");
new_bookmark->SetString("url", "http://froogle.com");
- toolbar_bookmarks->Append(new_bookmark);
+ toolbar_bookmarks->Append(new_bookmark.Pass());
ListValue* bookmark_list;
ASSERT_TRUE(settings.GetList("global.toolbar.bookmarks", &bookmark_list));
@@ -112,11 +112,12 @@
ASSERT_EQ(0U, binary->GetSize());
// Test the common case of a non-empty buffer
- char* buffer = new char[15];
- binary.reset(new BinaryValue(scoped_ptr<char[]>(buffer), 15));
+ scoped_ptr<char[]> buffer(new char[15]);
+ char* original_buffer = buffer.get();
+ binary.reset(new BinaryValue(buffer.Pass(), 15));
ASSERT_TRUE(binary.get());
ASSERT_TRUE(binary->GetBuffer());
- ASSERT_EQ(buffer, binary->GetBuffer());
+ ASSERT_EQ(original_buffer, binary->GetBuffer());
ASSERT_EQ(15U, binary->GetSize());
char stack_buffer[42];
@@ -194,14 +195,14 @@
{
ListValue list;
- list.Append(new DeletionTestValue(&deletion_flag));
+ list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
}
EXPECT_TRUE(deletion_flag);
{
ListValue list;
- list.Append(new DeletionTestValue(&deletion_flag));
+ list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
list.Clear();
EXPECT_TRUE(deletion_flag);
@@ -209,7 +210,7 @@
{
ListValue list;
- list.Append(new DeletionTestValue(&deletion_flag));
+ list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_TRUE(list.Set(0, Value::CreateNullValue()));
EXPECT_TRUE(deletion_flag);
@@ -222,7 +223,7 @@
{
ListValue list;
- list.Append(new DeletionTestValue(&deletion_flag));
+ list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_EQ(1U, list.GetSize());
EXPECT_FALSE(list.Remove(std::numeric_limits<size_t>::max(),
@@ -238,7 +239,7 @@
{
ListValue list;
- list.Append(new DeletionTestValue(&deletion_flag));
+ list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_TRUE(list.Remove(0, NULL));
EXPECT_TRUE(deletion_flag);
@@ -247,11 +248,12 @@
{
ListValue list;
- DeletionTestValue* value = new DeletionTestValue(&deletion_flag);
- list.Append(value);
+ scoped_ptr<DeletionTestValue> value(new DeletionTestValue(&deletion_flag));
+ DeletionTestValue* original_value = value.get();
+ list.Append(value.Pass());
EXPECT_FALSE(deletion_flag);
size_t index = 0;
- list.Remove(*value, &index);
+ list.Remove(*original_value, &index);
EXPECT_EQ(0U, index);
EXPECT_TRUE(deletion_flag);
EXPECT_EQ(0U, list.GetSize());
@@ -390,34 +392,47 @@
TEST(ValuesTest, DeepCopy) {
DictionaryValue original_dict;
- Value* original_null = Value::CreateNullValue();
- original_dict.Set("null", make_scoped_ptr(original_null));
- FundamentalValue* original_bool = new FundamentalValue(true);
- original_dict.Set("bool", make_scoped_ptr(original_bool));
- FundamentalValue* original_int = new FundamentalValue(42);
- original_dict.Set("int", make_scoped_ptr(original_int));
- FundamentalValue* original_double = new FundamentalValue(3.14);
- original_dict.Set("double", make_scoped_ptr(original_double));
- StringValue* original_string = new StringValue("hello");
- original_dict.Set("string", make_scoped_ptr(original_string));
- StringValue* original_string16 = new StringValue(ASCIIToUTF16("hello16"));
- original_dict.Set("string16", make_scoped_ptr(original_string16));
+ scoped_ptr<Value> scoped_null(Value::CreateNullValue());
+ Value* original_null = scoped_null.get();
+ original_dict.Set("null", scoped_null.Pass());
+ scoped_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
+ FundamentalValue* original_bool = scoped_bool.get();
+ original_dict.Set("bool", scoped_bool.Pass());
+ scoped_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
+ FundamentalValue* original_int = scoped_int.get();
+ original_dict.Set("int", scoped_int.Pass());
+ scoped_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
+ FundamentalValue* original_double = scoped_double.get();
+ original_dict.Set("double", scoped_double.Pass());
+ scoped_ptr<StringValue> scoped_string(new StringValue("hello"));
+ StringValue* original_string = scoped_string.get();
+ original_dict.Set("string", scoped_string.Pass());
+ scoped_ptr<StringValue> scoped_string16(
+ new StringValue(ASCIIToUTF16("hello16")));
+ StringValue* original_string16 = scoped_string16.get();
+ original_dict.Set("string16", scoped_string16.Pass());
scoped_ptr<char[]> original_buffer(new char[42]);
memset(original_buffer.get(), '!', 42);
- BinaryValue* original_binary = new BinaryValue(original_buffer.Pass(), 42);
- original_dict.Set("binary", original_binary);
+ scoped_ptr<BinaryValue> scoped_binary(
+ new BinaryValue(original_buffer.Pass(), 42));
+ BinaryValue* original_binary = scoped_binary.get();
+ original_dict.Set("binary", scoped_binary.Pass());
- ListValue* original_list = new ListValue();
- FundamentalValue* original_list_element_0 = new FundamentalValue(0);
- original_list->Append(original_list_element_0);
- FundamentalValue* original_list_element_1 = new FundamentalValue(1);
- original_list->Append(original_list_element_1);
- original_dict.Set("list", make_scoped_ptr(original_list));
+ scoped_ptr<ListValue> scoped_list(new ListValue());
+ Value* original_list = scoped_list.get();
+ scoped_ptr<FundamentalValue> scoped_list_element_0(new FundamentalValue(0));
+ Value* original_list_element_0 = scoped_list_element_0.get();
+ scoped_list->Append(scoped_list_element_0.Pass());
+ scoped_ptr<FundamentalValue> scoped_list_element_1(new FundamentalValue(1));
+ Value* original_list_element_1 = scoped_list_element_1.get();
+ scoped_list->Append(scoped_list_element_1.Pass());
+ original_dict.Set("list", scoped_list.Pass());
- DictionaryValue* original_nested_dictionary = new DictionaryValue();
- original_nested_dictionary->SetString("key", "value");
- original_dict.Set("dictionary", make_scoped_ptr(original_nested_dictionary));
+ scoped_ptr<DictionaryValue> scoped_nested_dictionary(new DictionaryValue());
+ Value* original_nested_dictionary = scoped_nested_dictionary.get();
+ scoped_nested_dictionary->SetString("key", "value");
+ original_dict.Set("dictionary", scoped_nested_dictionary.Pass());
scoped_ptr<DictionaryValue> copy_dict = original_dict.CreateDeepCopy();
ASSERT_TRUE(copy_dict.get());
@@ -529,16 +544,13 @@
}
TEST(ValuesTest, Equals) {
- Value* null1 = Value::CreateNullValue();
- Value* null2 = Value::CreateNullValue();
- EXPECT_NE(null1, null2);
- EXPECT_TRUE(null1->Equals(null2));
+ scoped_ptr<Value> null1(Value::CreateNullValue());
+ scoped_ptr<Value> null2(Value::CreateNullValue());
+ EXPECT_NE(null1.get(), null2.get());
+ EXPECT_TRUE(null1->Equals(null2.get()));
- Value* boolean = new FundamentalValue(false);
- EXPECT_FALSE(null1->Equals(boolean));
- delete null1;
- delete null2;
- delete boolean;
+ scoped_ptr<Value> boolean(new FundamentalValue(false));
+ EXPECT_FALSE(null1->Equals(boolean.get()));
DictionaryValue dv;
dv.SetBoolean("a", false);
@@ -551,16 +563,18 @@
scoped_ptr<DictionaryValue> copy = dv.CreateDeepCopy();
EXPECT_TRUE(dv.Equals(copy.get()));
- ListValue* list = new ListValue;
- list->Append(Value::CreateNullValue());
- list->Append(new DictionaryValue);
- dv.Set("f", make_scoped_ptr(list));
+ scoped_ptr<ListValue> list(new ListValue);
+ ListValue* original_list = list.get();
+ list->Append(make_scoped_ptr(Value::CreateNullValue()));
+ list->Append(make_scoped_ptr(new DictionaryValue));
+ scoped_ptr<Value> list_copy(list->CreateDeepCopy());
+ dv.Set("f", list.Pass());
EXPECT_FALSE(dv.Equals(copy.get()));
- copy->Set("f", list->CreateDeepCopy());
+ copy->Set("f", list_copy.Pass());
EXPECT_TRUE(dv.Equals(copy.get()));
- list->Append(new FundamentalValue(true));
+ original_list->Append(make_scoped_ptr(new FundamentalValue(true)));
EXPECT_FALSE(dv.Equals(copy.get()));
// Check if Equals detects differences in only the keys.
@@ -596,58 +610,60 @@
TEST(ValuesTest, DeepCopyCovariantReturnTypes) {
DictionaryValue original_dict;
- Value* original_null = Value::CreateNullValue();
- original_dict.Set("null", make_scoped_ptr(original_null));
- FundamentalValue* original_bool = new FundamentalValue(true);
- original_dict.Set("bool", make_scoped_ptr(original_bool));
- FundamentalValue* original_int = new FundamentalValue(42);
- original_dict.Set("int", make_scoped_ptr(original_int));
- FundamentalValue* original_double = new FundamentalValue(3.14);
- original_dict.Set("double", make_scoped_ptr(original_double));
- StringValue* original_string = new StringValue("hello");
- original_dict.Set("string", make_scoped_ptr(original_string));
- StringValue* original_string16 = new StringValue(ASCIIToUTF16("hello16"));
- original_dict.Set("string16", make_scoped_ptr(original_string16));
+ scoped_ptr<Value> scoped_null(Value::CreateNullValue());
+ Value* original_null = scoped_null.get();
+ original_dict.Set("null", scoped_null.Pass());
+ scoped_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
+ Value* original_bool = scoped_bool.get();
+ original_dict.Set("bool", scoped_bool.Pass());
+ scoped_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
+ Value* original_int = scoped_int.get();
+ original_dict.Set("int", scoped_int.Pass());
+ scoped_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
+ Value* original_double = scoped_double.get();
+ original_dict.Set("double", scoped_double.Pass());
+ scoped_ptr<StringValue> scoped_string(new StringValue("hello"));
+ Value* original_string = scoped_string.get();
+ original_dict.Set("string", scoped_string.Pass());
+ scoped_ptr<StringValue> scoped_string16(
+ new StringValue(ASCIIToUTF16("hello16")));
+ Value* original_string16 = scoped_string16.get();
+ original_dict.Set("string16", scoped_string16.Pass());
scoped_ptr<char[]> original_buffer(new char[42]);
memset(original_buffer.get(), '!', 42);
- BinaryValue* original_binary = new BinaryValue(original_buffer.Pass(), 42);
- original_dict.Set("binary", make_scoped_ptr(original_binary));
+ scoped_ptr<BinaryValue> scoped_binary(
+ new BinaryValue(original_buffer.Pass(), 42));
+ Value* original_binary = scoped_binary.get();
+ original_dict.Set("binary", scoped_binary.Pass());
- ListValue* original_list = new ListValue();
- FundamentalValue* original_list_element_0 = new FundamentalValue(0);
- original_list->Append(original_list_element_0);
- FundamentalValue* original_list_element_1 = new FundamentalValue(1);
- original_list->Append(original_list_element_1);
- original_dict.Set("list", make_scoped_ptr(original_list));
+ scoped_ptr<ListValue> scoped_list(new ListValue());
+ Value* original_list = scoped_list.get();
+ scoped_ptr<FundamentalValue> scoped_list_element_0(new FundamentalValue(0));
+ scoped_list->Append(scoped_list_element_0.Pass());
+ scoped_ptr<FundamentalValue> scoped_list_element_1(new FundamentalValue(1));
+ scoped_list->Append(scoped_list_element_1.Pass());
+ original_dict.Set("list", scoped_list.Pass());
- Value* original_dict_value = &original_dict;
- Value* original_bool_value = original_bool;
- Value* original_int_value = original_int;
- Value* original_double_value = original_double;
- Value* original_string_value = original_string;
- Value* original_string16_value = original_string16;
- Value* original_binary_value = original_binary;
- Value* original_list_value = original_list;
+ scoped_ptr<Value> copy_dict = original_dict.CreateDeepCopy();
+ scoped_ptr<Value> copy_null = original_null->CreateDeepCopy();
+ scoped_ptr<Value> copy_bool = original_bool->CreateDeepCopy();
+ scoped_ptr<Value> copy_int = original_int->CreateDeepCopy();
+ scoped_ptr<Value> copy_double = original_double->CreateDeepCopy();
+ scoped_ptr<Value> copy_string = original_string->CreateDeepCopy();
+ scoped_ptr<Value> copy_string16 = original_string16->CreateDeepCopy();
+ scoped_ptr<Value> copy_binary = original_binary->CreateDeepCopy();
+ scoped_ptr<Value> copy_list = original_list->CreateDeepCopy();
- scoped_ptr<Value> copy_dict_value = original_dict_value->CreateDeepCopy();
- scoped_ptr<Value> copy_bool_value = original_bool_value->CreateDeepCopy();
- scoped_ptr<Value> copy_int_value = original_int_value->CreateDeepCopy();
- scoped_ptr<Value> copy_double_value = original_double_value->CreateDeepCopy();
- scoped_ptr<Value> copy_string_value = original_string_value->CreateDeepCopy();
- scoped_ptr<Value> copy_string16_value =
- original_string16_value->CreateDeepCopy();
- scoped_ptr<Value> copy_binary_value = original_binary_value->CreateDeepCopy();
- scoped_ptr<Value> copy_list_value = original_list_value->CreateDeepCopy();
-
- EXPECT_TRUE(original_dict_value->Equals(copy_dict_value.get()));
- EXPECT_TRUE(original_bool_value->Equals(copy_bool_value.get()));
- EXPECT_TRUE(original_int_value->Equals(copy_int_value.get()));
- EXPECT_TRUE(original_double_value->Equals(copy_double_value.get()));
- EXPECT_TRUE(original_string_value->Equals(copy_string_value.get()));
- EXPECT_TRUE(original_string16_value->Equals(copy_string16_value.get()));
- EXPECT_TRUE(original_binary_value->Equals(copy_binary_value.get()));
- EXPECT_TRUE(original_list_value->Equals(copy_list_value.get()));
+ EXPECT_TRUE(original_dict.Equals(copy_dict.get()));
+ EXPECT_TRUE(original_null->Equals(copy_null.get()));
+ EXPECT_TRUE(original_bool->Equals(copy_bool.get()));
+ EXPECT_TRUE(original_int->Equals(copy_int.get()));
+ EXPECT_TRUE(original_double->Equals(copy_double.get()));
+ EXPECT_TRUE(original_string->Equals(copy_string.get()));
+ EXPECT_TRUE(original_string16->Equals(copy_string16.get()));
+ EXPECT_TRUE(original_binary->Equals(copy_binary.get()));
+ EXPECT_TRUE(original_list->Equals(copy_list.get()));
}
TEST(ValuesTest, RemoveEmptyChildren) {
@@ -662,7 +678,7 @@
// Make sure we don't prune too much.
root->SetBoolean("bool", true);
- root->Set("empty_dict", new DictionaryValue);
+ root->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
root->SetString("empty_string", std::string());
root.reset(root->DeepCopyWithoutEmptyChildren());
EXPECT_EQ(2U, root->size());
@@ -674,14 +690,14 @@
// Nested test cases. These should all reduce back to the bool and string
// set above.
{
- root->Set("a.b.c.d.e", new DictionaryValue);
+ root->Set("a.b.c.d.e", make_scoped_ptr(new DictionaryValue));
root.reset(root->DeepCopyWithoutEmptyChildren());
EXPECT_EQ(2U, root->size());
}
{
scoped_ptr<DictionaryValue> inner(new DictionaryValue);
- inner->Set("empty_dict", new DictionaryValue);
- inner->Set("empty_list", new ListValue);
+ inner->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
+ inner->Set("empty_list", make_scoped_ptr(new ListValue));
root->Set("dict_with_empty_children", inner.Pass());
root.reset(root->DeepCopyWithoutEmptyChildren());
EXPECT_EQ(2U, root->size());
@@ -713,7 +729,7 @@
{
scoped_ptr<ListValue> inner(new ListValue);
scoped_ptr<ListValue> inner2(new ListValue);
- inner2->Append(new StringValue("hello"));
+ inner2->Append(make_scoped_ptr(new StringValue("hello")));
inner->Append(make_scoped_ptr(new DictionaryValue));
inner->Append(inner2.Pass());
root->Set("list_with_empty_children", inner.Pass());
@@ -732,18 +748,18 @@
scoped_ptr<DictionaryValue> base(new DictionaryValue);
base->SetString("base_key", "base_key_value_base");
base->SetString("collide_key", "collide_key_value_base");
- DictionaryValue* base_sub_dict = new DictionaryValue;
+ scoped_ptr<DictionaryValue> base_sub_dict(new DictionaryValue);
base_sub_dict->SetString("sub_base_key", "sub_base_key_value_base");
base_sub_dict->SetString("sub_collide_key", "sub_collide_key_value_base");
- base->Set("sub_dict_key", base_sub_dict);
+ base->Set("sub_dict_key", base_sub_dict.Pass());
scoped_ptr<DictionaryValue> merge(new DictionaryValue);
merge->SetString("merge_key", "merge_key_value_merge");
merge->SetString("collide_key", "collide_key_value_merge");
- DictionaryValue* merge_sub_dict = new DictionaryValue;
+ scoped_ptr<DictionaryValue> merge_sub_dict(new DictionaryValue);
merge_sub_dict->SetString("sub_merge_key", "sub_merge_key_value_merge");
merge_sub_dict->SetString("sub_collide_key", "sub_collide_key_value_merge");
- merge->Set("sub_dict_key", merge_sub_dict);
+ merge->Set("sub_dict_key", merge_sub_dict.Pass());
base->MergeDictionary(merge.get());
@@ -774,7 +790,8 @@
}
TEST(ValuesTest, MergeDictionaryDeepCopy) {
- DictionaryValue* child = new DictionaryValue;
+ scoped_ptr<DictionaryValue> child(new DictionaryValue);
+ DictionaryValue* original_child = child.get();
child->SetString("test", "value");
EXPECT_EQ(1U, child->size());
@@ -783,22 +800,22 @@
EXPECT_EQ("value", value);
scoped_ptr<DictionaryValue> base(new DictionaryValue);
- base->Set("dict", child);
+ base->Set("dict", child.Pass());
EXPECT_EQ(1U, base->size());
DictionaryValue* ptr;
EXPECT_TRUE(base->GetDictionary("dict", &ptr));
- EXPECT_EQ(child, ptr);
+ EXPECT_EQ(original_child, ptr);
scoped_ptr<DictionaryValue> merged(new DictionaryValue);
merged->MergeDictionary(base.get());
EXPECT_EQ(1U, merged->size());
EXPECT_TRUE(merged->GetDictionary("dict", &ptr));
- EXPECT_NE(child, ptr);
+ EXPECT_NE(original_child, ptr);
EXPECT_TRUE(ptr->GetString("test", &value));
EXPECT_EQ("value", value);
- child->SetString("test", "overwrite");
+ original_child->SetString("test", "overwrite");
base.reset();
EXPECT_TRUE(ptr->GetString("test", &value));
EXPECT_EQ("value", value);
diff --git a/base/win/memory_pressure_monitor.h b/base/win/memory_pressure_monitor.h
index 6da176e..933d912 100644
--- a/base/win/memory_pressure_monitor.h
+++ b/base/win/memory_pressure_monitor.h
@@ -128,13 +128,13 @@
// |CalculateCurrentPressureLevel|.
int moderate_pressure_repeat_count_;
+ // Ensures that this object is used from a single thread.
+ base::ThreadChecker thread_checker_;
+
// Weak pointer factory to ourself used for scheduling calls to
// CheckMemoryPressure/CheckMemoryPressureAndRecordStatistics via |timer_|.
base::WeakPtrFactory<MemoryPressureMonitor> weak_ptr_factory_;
- // Ensures that this object is used from a single thread.
- base::ThreadChecker thread_checker_;
-
DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor);
};
diff --git a/build/android/buildbot/bb_device_steps.py b/build/android/buildbot/bb_device_steps.py
index d7975a3..53646e3 100755
--- a/build/android/buildbot/bb_device_steps.py
+++ b/build/android/buildbot/bb_device_steps.py
@@ -94,10 +94,21 @@
'ChromeDriverWebViewShell.apk',
'org.chromium.chromedriver_webview_shell')]))
-VALID_TESTS = set(['chromedriver', 'chrome_proxy', 'components_browsertests',
- 'gpu', 'python_unittests', 'telemetry_unittests',
- 'telemetry_perf_unittests', 'ui', 'unit', 'webkit',
- 'webkit_layout'])
+VALID_TESTS = set([
+ 'base_junit_tests',
+ 'chromedriver',
+ 'chrome_proxy',
+ 'components_browsertests',
+ 'gfx_unittests',
+ 'gpu',
+ 'python_unittests',
+ 'telemetry_unittests',
+ 'telemetry_perf_unittests',
+ 'ui',
+ 'unit',
+ 'webkit',
+ 'webkit_layout'
+])
RunCmd = bb_utils.RunCmd
@@ -178,6 +189,11 @@
_RunTest(options, cmd, suite)
+def RunJunitSuite(suite):
+ bb_annotations.PrintNamedStep(suite)
+ RunCmd(['build/android/test_runner.py', 'junit', '-s', suite])
+
+
def RunChromeDriverTests(options):
"""Run all the steps for running chromedriver tests."""
bb_annotations.PrintNamedStep('chromedriver_annotation')
@@ -561,10 +577,14 @@
def GetTestStepCmds():
return [
+ ('base_junit_tests',
+ lambda _options: RunJunitSuite('base_junit_tests')),
('chromedriver', RunChromeDriverTests),
('chrome_proxy', RunChromeProxyTests),
('components_browsertests',
lambda options: RunTestSuites(options, ['components_browsertests'])),
+ ('gfx_unittests',
+ lambda options: RunTestSuites(options, ['gfx_unittests'])),
('gpu', RunGPUTests),
('python_unittests', RunPythonUnitTests),
('telemetry_unittests', RunTelemetryUnitTests),
diff --git a/build/android/buildbot/bb_run_bot.py b/build/android/buildbot/bb_run_bot.py
index a6afb86..2b5f31a 100755
--- a/build/android/buildbot/bb_run_bot.py
+++ b/build/android/buildbot/bb_run_bot.py
@@ -124,6 +124,11 @@
telemetry_tests = ['telemetry_perf_unittests']
telemetry_tests_user_build = ['telemetry_unittests',
'telemetry_perf_unittests']
+ trial_tests = [
+ 'base_junit_tests',
+ 'components_browsertests',
+ 'gfx_unittests',
+ ]
flakiness_server = (
'--flakiness-server=%s' % constants.UPSTREAM_FLAKINESS_SERVER)
experimental = ['--experimental']
@@ -174,7 +179,7 @@
'--coverage-bucket', CHROMIUM_COVERAGE_BUCKET,
'--cleanup'])),
B('user-build-fyi-tests-dbg', H(std_test_steps),
- T(telemetry_tests_user_build + ['components_browsertests'])),
+ T(sorted(telemetry_tests_user_build + trial_tests))),
B('fyi-component-builder-tests-dbg',
H(compile_step, extra_gyp='component=shared_library'),
T(std_tests, ['--experimental', flakiness_server])),
diff --git a/build/android/gyp/copy_ex.py b/build/android/gyp/copy_ex.py
index eee3d19..a474e77 100755
--- a/build/android/gyp/copy_ex.py
+++ b/build/android/gyp/copy_ex.py
@@ -7,12 +7,23 @@
"""Copies files to a directory."""
import optparse
+import os
import shutil
import sys
from util import build_utils
+def _get_all_files(base):
+ """Returns a list of all the files in |base|. Each entry is relative to the
+ last path entry of |base|."""
+ result = []
+ dirname = os.path.dirname(base)
+ for root, _, files in os.walk(base):
+ result.extend([os.path.join(root[len(dirname):], f) for f in files])
+ return result
+
+
def main(args):
args = build_utils.ExpandFileArgs(args)
@@ -38,13 +49,24 @@
for file_arg in options.files:
files += build_utils.ParseGypList(file_arg)
+ deps = []
+
for f in files:
- shutil.copy(f, options.dest)
+ if os.path.isdir(f):
+ if not options.clear:
+ print ('To avoid stale files you must use --clear when copying '
+ 'directories')
+ sys.exit(-1)
+ shutil.copytree(f, os.path.join(options.dest, os.path.basename(f)))
+ deps.extend(_get_all_files(f))
+ else:
+ shutil.copy(f, options.dest)
+ deps.append(f)
if options.depfile:
build_utils.WriteDepfile(
options.depfile,
- files + build_utils.GetPythonDependencies())
+ deps + build_utils.GetPythonDependencies())
if options.stamp:
build_utils.Touch(options.stamp)
diff --git a/build/android/gyp/process_resources.py b/build/android/gyp/process_resources.py
index 4e6c27d..7a5fdf8 100755
--- a/build/android/gyp/process_resources.py
+++ b/build/android/gyp/process_resources.py
@@ -22,6 +22,10 @@
from util import build_utils
+# Import jinja2 from third_party/jinja2
+sys.path.append(os.path.join(os.path.dirname(__file__), '../../../third_party'))
+from jinja2 import Template # pylint: disable=F0401
+
def ParseArgs(args):
"""Parses command line options.
@@ -57,6 +61,8 @@
help='directory to hold generated R.java.')
parser.add_option('--srcjar-out',
help='Path to srcjar to contain generated R.java.')
+ parser.add_option('--r-text-out',
+ help='Path to store the R.txt file generated by appt.')
parser.add_option('--proguard-file',
help='Path to proguard.txt generated file')
@@ -71,13 +77,16 @@
parser.add_option(
'--extra-res-packages',
help='Additional package names to generate R.java files for')
- # TODO(cjhopman): Actually use --extra-r-text-files. We currently include all
- # the resources in all R.java files for a particular apk.
parser.add_option(
'--extra-r-text-files',
help='For each additional package, the R.txt file should contain a '
'list of resources to be included in the R.java file in the format '
'generated by aapt')
+ parser.add_option(
+ '--include-all-resources',
+ action='store_true',
+ help='Include every resource ID in every generated R.java file '
+ '(ignoring R.txt).')
parser.add_option(
'--all-resources-zip-out',
@@ -108,24 +117,104 @@
return options
-def CreateExtraRJavaFiles(r_dir, extra_packages):
- java_files = build_utils.FindInDirectory(r_dir, "R.java")
- if len(java_files) != 1:
- return
- r_java_file = java_files[0]
- r_java_contents = codecs.open(r_java_file, encoding='utf-8').read()
+def CreateExtraRJavaFiles(
+ r_dir, extra_packages, extra_r_text_files, shared_resources, include_all):
+ if include_all:
+ java_files = build_utils.FindInDirectory(r_dir, "R.java")
+ if len(java_files) != 1:
+ return
+ r_java_file = java_files[0]
+ r_java_contents = codecs.open(r_java_file, encoding='utf-8').read()
- for package in extra_packages:
- package_r_java_dir = os.path.join(r_dir, *package.split('.'))
- build_utils.MakeDirectory(package_r_java_dir)
- package_r_java_path = os.path.join(package_r_java_dir, 'R.java')
- new_r_java = re.sub(r'package [.\w]*;', u'package %s;' % package,
- r_java_contents)
- codecs.open(package_r_java_path, 'w', encoding='utf-8').write(new_r_java)
- # TODO(cjhopman): These extra package's R.java files should be filtered to
- # only contain the resources listed in their R.txt files. At this point, we
- # have already compiled those other libraries, so doing this would only
- # affect how the code in this .apk target could refer to the resources.
+ for package in extra_packages:
+ package_r_java_dir = os.path.join(r_dir, *package.split('.'))
+ build_utils.MakeDirectory(package_r_java_dir)
+ package_r_java_path = os.path.join(package_r_java_dir, 'R.java')
+ new_r_java = re.sub(r'package [.\w]*;', u'package %s;' % package,
+ r_java_contents)
+ codecs.open(package_r_java_path, 'w', encoding='utf-8').write(new_r_java)
+ else:
+ if len(extra_packages) != len(extra_r_text_files):
+ raise Exception('Need one R.txt file per extra package')
+
+ all_resources = {}
+ r_txt_file = os.path.join(r_dir, 'R.txt')
+ if not os.path.exists(r_txt_file):
+ return
+ with open(r_txt_file) as f:
+ for line in f:
+ m = re.match(r'(int(?:\[\])?) (\w+) (\w+) (.+)$', line)
+ if not m:
+ raise Exception('Unexpected line in R.txt: %s' % line)
+ java_type, resource_type, name, value = m.groups()
+ all_resources[(resource_type, name)] = (java_type, value)
+
+ for package, r_text_file in zip(extra_packages, extra_r_text_files):
+ if os.path.exists(r_text_file):
+ package_r_java_dir = os.path.join(r_dir, *package.split('.'))
+ build_utils.MakeDirectory(package_r_java_dir)
+ package_r_java_path = os.path.join(package_r_java_dir, 'R.java')
+ CreateExtraRJavaFile(
+ package, package_r_java_path, r_text_file, all_resources,
+ shared_resources)
+
+
+def CreateExtraRJavaFile(
+ package, r_java_path, r_text_file, all_resources, shared_resources):
+ resources = {}
+ with open(r_text_file) as f:
+ for line in f:
+ m = re.match(r'int(?:\[\])? (\w+) (\w+) ', line)
+ if not m:
+ raise Exception('Unexpected line in R.txt: %s' % line)
+ resource_type, name = m.groups()
+ java_type, value = all_resources[(resource_type, name)]
+ if resource_type not in resources:
+ resources[resource_type] = []
+ resources[resource_type].append((name, java_type, value))
+
+ template = Template("""/* AUTO-GENERATED FILE. DO NOT MODIFY. */
+
+package {{ package }};
+
+public final class R {
+ {% for resource_type in resources %}
+ public static final class {{ resource_type }} {
+ {% for name, java_type, value in resources[resource_type] %}
+ {% if shared_resources %}
+ public static {{ java_type }} {{ name }} = {{ value }};
+ {% else %}
+ public static final {{ java_type }} {{ name }} = {{ value }};
+ {% endif %}
+ {% endfor %}
+ }
+ {% endfor %}
+ {% if shared_resources %}
+ public static void onResourcesLoaded(int packageId) {
+ {% for resource_type in resources %}
+ {% for name, java_type, value in resources[resource_type] %}
+ {% if java_type == 'int[]' %}
+ for(int i = 0; i < {{ resource_type }}.{{ name }}.length; ++i) {
+ {{ resource_type }}.{{ name }}[i] =
+ ({{ resource_type }}.{{ name }}[i] & 0x00ffffff)
+ | (packageId << 24);
+ }
+ {% else %}
+ {{ resource_type }}.{{ name }} =
+ ({{ resource_type }}.{{ name }} & 0x00ffffff)
+ | (packageId << 24);
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+ }
+ {% endif %}
+}
+""", trim_blocks=True, lstrip_blocks=True)
+
+ output = template.render(package=package, resources=resources,
+ shared_resources=shared_resources)
+ with open(r_java_path, 'w') as f:
+ f.write(output)
def CrunchDirectory(aapt, input_dir, output_dir):
@@ -280,7 +369,10 @@
if options.extra_res_packages:
CreateExtraRJavaFiles(
gen_dir,
- build_utils.ParseGypList(options.extra_res_packages))
+ build_utils.ParseGypList(options.extra_res_packages),
+ build_utils.ParseGypList(options.extra_r_text_files),
+ options.shared_resources,
+ options.include_all_resources)
# This is the list of directories with resources to put in the final .zip
# file. The order of these is important so that crunched/v14 resources
@@ -310,6 +402,13 @@
else:
build_utils.ZipDir(options.srcjar_out, gen_dir)
+ if options.r_text_out:
+ r_text_path = os.path.join(gen_dir, 'R.txt')
+ if os.path.exists(r_text_path):
+ shutil.copyfile(r_text_path, options.r_text_out)
+ else:
+ open(options.r_text_out, 'w').close()
+
if options.depfile:
input_files += build_utils.GetPythonDependencies()
build_utils.WriteDepfile(options.depfile, input_files)
diff --git a/build/android/gyp/write_build_config.py b/build/android/gyp/write_build_config.py
index 1b4379d..0f3bfad 100755
--- a/build/android/gyp/write_build_config.py
+++ b/build/android/gyp/write_build_config.py
@@ -100,6 +100,7 @@
# android_resources options
parser.add_option('--srcjar', help='Path to target\'s resources srcjar.')
parser.add_option('--resources-zip', help='Path to target\'s resources zip.')
+ parser.add_option('--r-text', help='Path to target\'s R.txt file.')
parser.add_option('--package-name',
help='Java package name for these resources.')
parser.add_option('--android-manifest', help='Path to android manifest.')
@@ -237,18 +238,26 @@
deps_info['resources_zip'] = options.resources_zip
if options.srcjar:
deps_info['srcjar'] = options.srcjar
+ if options.android_manifest:
+ manifest = AndroidManifest(options.android_manifest)
+ deps_info['package_name'] = manifest.GetPackageName()
if options.package_name:
deps_info['package_name'] = options.package_name
+ if options.r_text:
+ deps_info['r_text'] = options.r_text
if options.type == 'android_resources' or options.type == 'android_apk':
config['resources'] = {}
config['resources']['dependency_zips'] = [
c['resources_zip'] for c in all_resources_deps]
config['resources']['extra_package_names'] = []
+ config['resources']['extra_r_text_files'] = []
if options.type == 'android_apk':
config['resources']['extra_package_names'] = [
c['package_name'] for c in all_resources_deps if 'package_name' in c]
+ config['resources']['extra_r_text_files'] = [
+ c['r_text'] for c in all_resources_deps if 'r_text' in c]
if options.type in ['android_apk', 'deps_dex']:
deps_dex_files = [c['dex_path'] for c in all_library_deps]
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py
index dbb3297..b366f0c 100755
--- a/build/android/provision_devices.py
+++ b/build/android/provision_devices.py
@@ -247,7 +247,7 @@
# Launch adb_reboot
logging.info(' Launching adb_reboot ...')
device.RunShellCommand(
- [device.GetDevicePieWrapper(), '/data/local/tmp/adb_reboot'],
+ ['/data/local/tmp/adb_reboot'],
check_return=True)
diff --git a/build/android/pylib/base/base_setup.py b/build/android/pylib/base/base_setup.py
index c276822..0b0daf1 100644
--- a/build/android/pylib/base/base_setup.py
+++ b/build/android/pylib/base/base_setup.py
@@ -23,6 +23,8 @@
the test suites.
deps_exclusion_list: A list of files that are listed as dependencies in the
.isolate files but should not be pushed to the device.
+ Returns:
+ The Isolator instance used to remap the dependencies, or None.
"""
if isolate_file_path:
if os.path.isabs(isolate_file_path):
@@ -51,6 +53,7 @@
i.VerifyHardlinks()
i.PurgeExcluded(deps_exclusion_list)
i.MoveOutputDeps()
+ return i
def PushDataDeps(device, device_dir, test_options):
diff --git a/build/android/pylib/constants/__init__.py b/build/android/pylib/constants/__init__.py
index 025860c..cb5f899 100644
--- a/build/android/pylib/constants/__init__.py
+++ b/build/android/pylib/constants/__init__.py
@@ -169,8 +169,6 @@
http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
"""
- ICE_CREAM_SANDWICH = 14
- ICE_CREAM_SANDWICH_MR1 = 15
JELLY_BEAN = 16
JELLY_BEAN_MR1 = 17
JELLY_BEAN_MR2 = 18
diff --git a/build/android/pylib/content_settings.py b/build/android/pylib/content_settings.py
index f039c96..8594140 100644
--- a/build/android/pylib/content_settings.py
+++ b/build/android/pylib/content_settings.py
@@ -14,9 +14,6 @@
def __init__(self, table, device):
super(ContentSettings, self).__init__()
- assert (device.build_version_sdk
- >= constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN), (
- 'ContentSettings supported only on SDK 16 and later')
self._table = table
self._device = device
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index 091bb8e..967809f 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -789,7 +789,7 @@
def SendKeyEvent(self, keycode, timeout=None, retries=None):
"""Sends a keycode to the device.
- See: http://developer.android.com/reference/android/view/KeyEvent.html
+ See the pylib.constants.keyevent module for suitable keycode values.
Args:
keycode: A integer keycode to send to the device.
@@ -1534,41 +1534,6 @@
"""
return logcat_monitor.LogcatMonitor(self.adb, *args, **kwargs)
- @decorators.WithTimeoutAndRetriesFromInstance()
- def GetDevicePieWrapper(self, timeout=None, retries=None):
- """Gets the absolute path to the run_pie wrapper on the device.
-
- We have to build our device executables to be PIE, but they need to be able
- to run on versions of android that don't support PIE (i.e. ICS and below).
- To do so, we push a wrapper to the device that lets older android versions
- run PIE executables. This method pushes that wrapper to the device if
- necessary and returns the path to it.
-
- This is exposed publicly to allow clients to write scripts using run_pie
- (e.g. md5sum.CalculateDeviceMd5Sum).
-
- Args:
- timeout: timeout in seconds
- retries: number of retries
-
- Returns:
- The path to the PIE wrapper on the device, or an empty string if the
- device does not require the wrapper.
- """
- if 'run_pie' not in self._cache:
- pie = ''
- if (self.build_version_sdk <
- constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN):
- host_pie_path = os.path.join(constants.GetOutDirectory(), 'run_pie')
- if not os.path.exists(host_pie_path):
- raise device_errors.CommandFailedError('Please build run_pie')
- pie = '%s/run_pie' % constants.TEST_EXECUTABLE_DIR
- self.adb.Push(host_pie_path, pie)
-
- self._cache['run_pie'] = pie
-
- return self._cache['run_pie']
-
def GetClientCache(self, client_name):
"""Returns client cache."""
if client_name not in self._client_caches:
diff --git a/build/android/pylib/device/device_utils_test.py b/build/android/pylib/device/device_utils_test.py
index e5e3936..23a1a32 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -731,24 +731,6 @@
self.assertIs(None, ec.exception.status)
-class DeviceUtilsGetDevicePieWrapper(DeviceUtilsTest):
-
- def testGetDevicePieWrapper_jb(self):
- with self.assertCall(
- self.call.device.build_version_sdk(),
- constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN):
- self.assertEqual('', self.device.GetDevicePieWrapper())
-
- def testGetDevicePieWrapper_ics(self):
- with self.assertCalls(
- (self.call.device.build_version_sdk(),
- constants.ANDROID_SDK_VERSION_CODES.ICE_CREAM_SANDWICH),
- (mock.call.pylib.constants.GetOutDirectory(), '/foo/bar'),
- (mock.call.os.path.exists(mock.ANY), True),
- (self.call.adb.Push(mock.ANY, mock.ANY), '')):
- self.assertNotEqual('', self.device.GetDevicePieWrapper())
-
-
@mock.patch('time.sleep', mock.Mock())
class DeviceUtilsKillAllTest(DeviceUtilsTest):
diff --git a/build/android/pylib/device_settings.py b/build/android/pylib/device_settings.py
index 73ffa72..97e9663 100644
--- a/build/android/pylib/device_settings.py
+++ b/build/android/pylib/device_settings.py
@@ -29,16 +29,6 @@
desired_settings: A list of (table, [(key: value), ...]) for all
settings to configure.
"""
- try:
- sdk_version = device.build_version_sdk
- except device_errors.CommandFailedError as exc:
- logging.error('Skipping content settings configuration: %s', str(exc))
- return
-
- if sdk_version < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN:
- logging.error('Skipping content settings configuration due to outdated sdk')
- return
-
if device.build_type == 'userdebug':
for table, key_value in desired_settings:
settings = content_settings.ContentSettings(table, device)
diff --git a/build/android/pylib/gtest/setup.py b/build/android/pylib/gtest/setup.py
index 2676152..d51b90e 100644
--- a/build/android/pylib/gtest/setup.py
+++ b/build/android/pylib/gtest/setup.py
@@ -207,7 +207,7 @@
test_package = exe_test_package
logging.warning('Found target %s', test_package.suite_path)
- base_setup.GenerateDepsDirUsingIsolate(test_options.suite_name,
+ i = base_setup.GenerateDepsDirUsingIsolate(test_options.suite_name,
test_options.isolate_file_path,
ISOLATE_FILE_PATHS,
DEPS_EXCLUSION_LIST)
@@ -217,6 +217,8 @@
else device.GetExternalStoragePath())
base_setup.PushDataDeps(device, device_dir, test_options)
device_utils.DeviceUtils.parallel(devices).pMap(push_data_deps_to_device_dir)
+ if i:
+ i.Clear()
tests = _GetTests(test_options, test_package, devices)
diff --git a/build/android/pylib/gtest/test_package_exe.py b/build/android/pylib/gtest/test_package_exe.py
index aa3374e..7cdcb99 100644
--- a/build/android/pylib/gtest/test_package_exe.py
+++ b/build/android/pylib/gtest/test_package_exe.py
@@ -116,9 +116,8 @@
constants.TEST_EXECUTABLE_DIR, '%s_deps' % self.suite_name)
cmd = []
- for wrapper in (device.GetDevicePieWrapper(), self.tool.GetTestWrapper()):
- if wrapper:
- cmd.append(wrapper)
+ if self.tool.GetTestWrapper():
+ cmd.append(self.tool.GetTestWrapper())
cmd.extend([
posixpath.join(constants.TEST_EXECUTABLE_DIR, self.suite_name),
'--gtest_list_tests'])
diff --git a/build/android/pylib/instrumentation/setup.py b/build/android/pylib/instrumentation/setup.py
index bdde80d..7a0501e 100644
--- a/build/android/pylib/instrumentation/setup.py
+++ b/build/android/pylib/instrumentation/setup.py
@@ -91,7 +91,7 @@
_PushDataDeps, test_options)
if test_options.isolate_file_path:
- base_setup.GenerateDepsDirUsingIsolate(test_options.test_apk,
+ i = base_setup.GenerateDepsDirUsingIsolate(test_options.test_apk,
test_options.isolate_file_path,
ISOLATE_FILE_PATHS,
DEPS_EXCLUSION_LIST)
@@ -100,6 +100,8 @@
test_options)
device_utils.DeviceUtils.parallel(devices).pMap(
push_data_deps_to_device_dir)
+ if i:
+ i.Clear()
device_utils.DeviceUtils.parallel(devices).pMap(
_PushExtraSuiteDataDeps, test_options.test_apk)
diff --git a/build/android/pylib/instrumentation/test_runner.py b/build/android/pylib/instrumentation/test_runner.py
index 6e8be34..d1c5a4d 100644
--- a/build/android/pylib/instrumentation/test_runner.py
+++ b/build/android/pylib/instrumentation/test_runner.py
@@ -336,9 +336,6 @@
timeout = (self._GetIndividualTestTimeoutSecs(test) *
self._GetIndividualTestTimeoutScale(test) *
self.tool.GetTimeoutScale())
- if (self.device.build_version_sdk
- < constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN):
- timeout *= 10
start_ms = 0
duration_ms = 0
diff --git a/build/android/pylib/utils/md5sum.py b/build/android/pylib/utils/md5sum.py
index d59245c..ed2e6bc 100644
--- a/build/android/pylib/utils/md5sum.py
+++ b/build/android/pylib/utils/md5sum.py
@@ -18,7 +18,7 @@
MD5SUM_DEVICE_SCRIPT_FORMAT = (
'test -f {path} -o -d {path} '
- '&& LD_LIBRARY_PATH={md5sum_lib} {device_pie_wrapper} {md5sum_bin} {path}')
+ '&& LD_LIBRARY_PATH={md5sum_lib} {md5sum_bin} {path}')
_STARTS_WITH_CHECKSUM_RE = re.compile(r'^\s*[0-9a-fA-f]{32}\s+')
@@ -65,11 +65,9 @@
with tempfile.NamedTemporaryFile() as md5sum_script_file:
with device_temp_file.DeviceTempFile(
device.adb) as md5sum_device_script_file:
- device_pie_wrapper = device.GetDevicePieWrapper()
md5sum_script = (
MD5SUM_DEVICE_SCRIPT_FORMAT.format(
path=p, md5sum_lib=MD5SUM_DEVICE_LIB_PATH,
- device_pie_wrapper=device_pie_wrapper,
md5sum_bin=MD5SUM_DEVICE_BIN_PATH)
for p in paths)
md5sum_script_file.write('; '.join(md5sum_script))
diff --git a/build/android/test_runner.py b/build/android/test_runner.py
index b9d2a3f..b71f805 100755
--- a/build/android/test_runner.py
+++ b/build/android/test_runner.py
@@ -659,9 +659,6 @@
if args.json_results_file:
json_results.GenerateJsonResultsFile(results, args.json_results_file)
- if os.path.isdir(constants.ISOLATE_DEPS_DIR):
- shutil.rmtree(constants.ISOLATE_DEPS_DIR)
-
return exit_code
diff --git a/build/common.gypi b/build/common.gypi
index bd38fc0..5cab295 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -1811,9 +1811,6 @@
'p2p_apis%' : 0,
'gtest_target_type%': 'shared_library',
-
- # Uses system APIs for decoding audio and video.
- 'use_libffmpeg%': '0',
}], # OS=="android"
['embedded==1', {
'use_system_fontconfig%': 0,
@@ -2245,9 +2242,9 @@
],
}],
- ['OS=="win"', {
- # The Blink GC plugin doesn't currently work on Windows.
- # TODO(hans): One day, this will work. (crbug.com/82385)
+ ['OS=="win" and target_arch=="x64"', {
+ # TODO(thakis): Enable on x64 once all warnings are fixed.
+ # http://crbug.com/486571
'blink_gc_plugin%': 0,
}],
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni
index ab773ea..2a7a892 100644
--- a/build/config/android/internal_rules.gni
+++ b/build/config/android/internal_rules.gni
@@ -323,6 +323,12 @@
invoker.custom_package,
]
}
+ if (defined(invoker.r_text)) {
+ args += [
+ "--r-text",
+ rebase_path(invoker.r_text, root_build_dir),
+ ]
+ }
}
if (is_apk) {
@@ -1005,6 +1011,7 @@
zip_path = invoker.zip_path
srcjar_path = invoker.srcjar_path
+ r_text_path = invoker.r_text_path
build_config = invoker.build_config
resource_dirs = invoker.resource_dirs
android_manifest = invoker.android_manifest
@@ -1022,6 +1029,7 @@
depfile,
zip_path,
srcjar_path,
+ r_text_path,
]
sources_build_rel = exec_script("//build/android/gyp/find.py",
@@ -1050,8 +1058,11 @@
rebase_path(srcjar_path, root_build_dir),
"--resource-zip-out",
rebase_path(zip_path, root_build_dir),
+ "--r-text-out",
+ rebase_path(r_text_path, root_build_dir),
"--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependency_zips)",
"--extra-res-packages=@FileArg($rebase_build_config:resources:extra_package_names)",
+ "--extra-r-text-files=@FileArg($rebase_build_config:resources:extra_r_text_files)",
]
if (non_constant_id) {
@@ -1073,6 +1084,11 @@
args += [ "--shared-resources" ]
}
+ if (defined(invoker.include_all_resources) &&
+ invoker.include_all_resources) {
+ args += [ "--include-all-resources" ]
+ }
+
if (defined(invoker.all_resources_zip_path)) {
all_resources_zip = invoker.all_resources_zip_path
outputs += [ all_resources_zip ]
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index b1b23b0..168ebb4 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -530,6 +530,7 @@
# shared_resources: If true make a resource package that can be loaded by a
# different application at runtime to access the package's resources.
#
+
# Example
# android_resources("foo_resources") {
# deps = [":foo_strings_grd"]
@@ -548,12 +549,14 @@
base_path = "$target_gen_dir/$target_name"
zip_path = base_path + ".resources.zip"
srcjar_path = base_path + ".srcjar"
+ r_text_path = base_path + "_R.txt"
build_config = base_path + ".build_config"
write_build_config("${target_name}__build_config") {
type = "android_resources"
resources_zip = zip_path
srcjar = srcjar_path
+ r_text = r_text_path
if (defined(invoker.deps)) {
deps = invoker.deps
}
@@ -1163,6 +1166,8 @@
# also be included in the apk.
# apk_under_test: For an instrumentation test apk, this is the target of the
# tested apk.
+# include_all_resources - If true include all resource IDs in all generated
+# R.java files.
# testonly: Marks this target as "test-only".
#
# DEPRECATED_java_in_dir: Directory containing java files. All .java files in
@@ -1306,11 +1311,16 @@
final_deps += [ ":${_template_name}__process_resources" ]
process_resources("${_template_name}__process_resources") {
srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
+ r_text_path = "${target_gen_dir}/${target_name}_R.txt"
android_manifest = _android_manifest
resource_dirs = [ "//build/android/ant/empty/res" ]
zip_path = resources_zip_path
generate_constant_ids = true
build_config = _build_config
+
+ if (defined(invoker.include_all_resources)) {
+ include_all_resources = invoker.include_all_resources
+ }
}
_srcjar_deps += [ ":${_template_name}__process_resources" ]
diff --git a/build/get_landmines.py b/build/get_landmines.py
index 8f5b878..71345bb 100755
--- a/build/get_landmines.py
+++ b/build/get_landmines.py
@@ -69,6 +69,8 @@
print 'Another clobber for missing NaCl gyp deps (crbug.com/427427).'
print 'Clobber to fix GN not picking up increased ID range (crbug.com/444902)'
print 'Remove NaCl toolchains from the output dir (crbug.com/456902)'
+ if platform() == 'ios':
+ print 'Clobber iOS to workaround Xcode deps bug (crbug.com/485435)'
def main():
diff --git a/build/java_apk.gypi b/build/java_apk.gypi
index 2af3a8a..cece2be 100644
--- a/build/java_apk.gypi
+++ b/build/java_apk.gypi
@@ -47,6 +47,8 @@
# application at runtime to access the package's resources.
# R_package - A custom Java package to generate the resource file R.java in.
# By default, the package given in AndroidManifest.xml will be used.
+# include_all_resources - Set to 1 to include all resource IDs in all generated
+# R.java files.
# use_chromium_linker - Enable the content dynamic linker that allows sharing the
# RELRO section of the native libraries between the different processes.
# load_library_from_zip_file - When using the dynamic linker, load the library
@@ -78,6 +80,7 @@
'jar_name': 'chromium_apk_<(_target_name).jar',
'resource_dir%':'<(DEPTH)/build/android/ant/empty/res',
'R_package%':'',
+ 'include_all_resources%': 0,
'additional_R_text_files': [],
'dependencies_res_zip_paths': [],
'additional_res_packages': [],
@@ -610,6 +613,12 @@
['shared_resources == 1', {
'process_resources_options+': ['--shared-resources']
}],
+ ['R_package != ""', {
+ 'process_resources_options+': ['--custom-package', '<(R_package)']
+ }],
+ ['include_all_resources == 1', {
+ 'process_resources_options+': ['--include-all-resources']
+ }]
],
},
'inputs': [
diff --git a/build/secondary/testing/BUILD.gn b/build/secondary/testing/BUILD.gn
deleted file mode 100644
index fc50637..0000000
--- a/build/secondary/testing/BUILD.gn
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2014 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.
-
-source_set("gmock_mutant") {
- sources = [
- "gmock_mutant.h", # gMock helpers
- ]
-
- deps = [
- "//base",
- ]
-}
diff --git a/tools/clang/scripts/blink_gc_plugin_flags.sh b/tools/clang/scripts/blink_gc_plugin_flags.sh
index 96dcade..1c883c5 100755
--- a/tools/clang/scripts/blink_gc_plugin_flags.sh
+++ b/tools/clang/scripts/blink_gc_plugin_flags.sh
@@ -3,32 +3,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# This script returns the flags that should be passed to clang.
-
-SRC_DIR=$(cd $(dirname $0)/../../.. && echo $PWD)
-CLANG_LIB_PATH=$SRC_DIR/third_party/llvm-build/Release+Asserts/lib
-
-if uname -s | grep -q Darwin; then
- LIBSUFFIX=dylib
-else
- LIBSUFFIX=so
-fi
-
-FLAGS=""
-PREFIX="-Xclang -plugin-arg-blink-gc-plugin -Xclang"
-for arg in "$@"; do
- if [[ "$arg" = "enable-oilpan=1" ]]; then
- FLAGS="$FLAGS $PREFIX enable-oilpan"
- elif [[ "$arg" = "dump-graph=1" ]]; then
- FLAGS="$FLAGS $PREFIX dump-graph"
- elif [[ "$arg" = "warn-raw-ptr=1" ]]; then
- FLAGS="$FLAGS $PREFIX warn-raw-ptr"
- elif [[ "$arg" = "warn-unneeded-finalizer=1" ]]; then
- FLAGS="$FLAGS $PREFIX warn-unneeded-finalizer"
- elif [[ "$arg" = custom_clang_lib_path=* ]]; then
- CLANG_LIB_PATH="$(cd "${arg#*=}" && echo $PWD)"
- fi
-done
-
-echo -Xclang -load -Xclang \"$CLANG_LIB_PATH/libBlinkGCPlugin.$LIBSUFFIX\" \
- -Xclang -add-plugin -Xclang blink-gc-plugin $FLAGS
+# TODO(thakis): Remove this script once Source/config.gyp refers the the .py
+# file.
+THIS_DIR="$(dirname "${0}")"
+ABS_THIS_DIR="${PWD}/${THIS_DIR}"
+exec python "${ABS_THIS_DIR}/blink_gc_plugin_flags.py" "$@"
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
index a1b369f..34356e2 100755
--- a/tools/clang/scripts/update.py
+++ b/tools/clang/scripts/update.py
@@ -23,8 +23,10 @@
# ASan on Windows is useful enough to use it even while the clang/win is still
# in bringup. Use a pinned revision to make it slightly more stable.
-if (re.search(r'\b(asan)=1', os.environ.get('GYP_DEFINES', '')) and
- not 'LLVM_FORCE_HEAD_REVISION' in os.environ):
+use_head_revision = ('LLVM_FORCE_HEAD_REVISION' in os.environ or
+ not re.search(r'\b(asan)=1', os.environ.get('GYP_DEFINES', '')))
+
+if not use_head_revision:
LLVM_WIN_REVISION = '235968'
# Path constants. (All of these should be absolute paths.)
@@ -234,8 +236,20 @@
os.makedirs(LLVM_BUILD_DIR)
os.chdir(LLVM_BUILD_DIR)
+ # If building at head, define a macro that plugins can use for #ifdefing
+ # out code that builds at head, but not at CLANG_REVISION or vice versa.
+ cflags = cxxflags = ''
+
+ # TODO(thakis): Set this only conditionally if use_head_revision once posix
+ # and win clang are in sync. At the moment, the plugins only build at clang
+ # head on posix, but they build at both head and the pinned win version :-/
+ cflags += ' -DLLVM_FORCE_HEAD_REVISION'
+ cxxflags += ' -DLLVM_FORCE_HEAD_REVISION'
+
cmake_args = ['-GNinja', '-DCMAKE_BUILD_TYPE=Release',
'-DLLVM_ENABLE_ASSERTIONS=ON', SubversionCmakeArg(),
+ '-DCMAKE_C_FLAGS=' + cflags,
+ '-DCMAKE_CXX_FLAGS=' + cxxflags,
'-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(
CHROMIUM_DIR, 'tools', 'clang'),
'-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)]
@@ -309,7 +323,8 @@
stderr=stderr)
parser = argparse.ArgumentParser(description='Build Clang.')
- parser.add_argument('--tools', nargs='*', default=['plugins'])
+ parser.add_argument('--tools', nargs='*',
+ default=['plugins', 'blink_gc_plugin'])
# For now, this flag is only used for the non-Windows flow, but argparser gets
# mad if it sees a flag it doesn't recognize.
parser.add_argument('--if-needed', action='store_true')