libbrillo: Update libchrome APIs to r395517
The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.
BUG: 28985443
TEST: All tests in libbrillo_test pass on dragonboard-eng build
CQ-DEPEND=CL:346457
Change-Id: Ie9343893a77b3638e03e89e3090ef61868d43c3b
(cherry picked from commit 4ec4c4d2e4f8ac46ea8e767c1ed88242811a8f4d)
Reviewed-on: https://chromium-review.googlesource.com/349110
Commit-Ready: Heng-ruey Hsu <henryhsu@google.com>
Tested-by: Heng-ruey Hsu <henryhsu@google.com>
Reviewed-by: Luis Hector Chavez <lhchavez@google.com>
diff --git a/brillo/asynchronous_signal_handler.h b/brillo/asynchronous_signal_handler.h
index f43b9c9..ceae1ff 100644
--- a/brillo/asynchronous_signal_handler.h
+++ b/brillo/asynchronous_signal_handler.h
@@ -13,7 +13,6 @@
#include <base/callback.h>
#include <base/compiler_specific.h>
#include <base/macros.h>
-#include <base/memory/scoped_ptr.h>
#include <base/message_loop/message_loop.h>
#include <brillo/asynchronous_signal_handler_interface.h>
#include <brillo/brillo_export.h>
diff --git a/brillo/bind_lambda.h b/brillo/bind_lambda.h
index 687ae1a..18c3212 100644
--- a/brillo/bind_lambda.h
+++ b/brillo/bind_lambda.h
@@ -31,7 +31,7 @@
public:
typedef R(RunType)(Args...);
LambdaAdapter(Lambda lambda) : lambda_(lambda) {}
- R Run(Args... args) { return lambda_(CallbackForward(args)...); }
+ R Run(Args... args) { return lambda_(std::forward<Args>(args)...); }
private:
Lambda lambda_;
@@ -43,7 +43,7 @@
public:
typedef R(RunType)(Args...);
LambdaAdapter(Lambda lambda) : lambda_(lambda) {}
- R Run(Args... args) { return lambda_(CallbackForward(args)...); }
+ R Run(Args... args) { return lambda_(std::forward<Args>(args)...); }
private:
Lambda lambda_;
diff --git a/brillo/dbus/utils.cc b/brillo/dbus/utils.cc
index d2e4ac6..c9bb4db 100644
--- a/brillo/dbus/utils.cc
+++ b/brillo/dbus/utils.cc
@@ -8,7 +8,6 @@
#include <vector>
#include <base/bind.h>
-#include <base/memory/scoped_ptr.h>
#include <brillo/errors/error_codes.h>
#include <brillo/strings/string_utils.h>
diff --git a/brillo/glib/object.h b/brillo/glib/object.h
index b9f2079..dfa96b6 100644
--- a/brillo/glib/object.h
+++ b/brillo/glib/object.h
@@ -10,10 +10,10 @@
#include <base/logging.h>
#include <base/macros.h>
-#include <base/memory/scoped_ptr.h>
#include <algorithm>
#include <cstddef>
+#include <memory>
#include <string>
namespace brillo {
@@ -61,7 +61,7 @@
// *x = new int(10);
// }
// ...
-// scoped_ptr<int> x;
+// std::unique_ptr<int> x;
// function(Resetter(x).lvalue());
//
// \end_example
@@ -314,7 +314,7 @@
}
};
-typedef ::scoped_ptr< ::GError, FreeError> ScopedError;
+typedef std::unique_ptr< ::GError, FreeError> ScopedError;
// \brief ScopedArray holds a ::GArray* and deletes both the container and the
// segment containing the elements on destruction.
@@ -326,7 +326,7 @@
}
};
-typedef ::scoped_ptr< ::GArray, FreeArray> ScopedArray;
+typedef std::unique_ptr< ::GArray, FreeArray> ScopedArray;
// \brief ScopedPtrArray adapts ::GPtrArray* to conform to the standard
// container requirements.
diff --git a/brillo/glib/object_unittest.cc b/brillo/glib/object_unittest.cc
index 5bc4b85..a1ed408 100644
--- a/brillo/glib/object_unittest.cc
+++ b/brillo/glib/object_unittest.cc
@@ -56,7 +56,7 @@
} // namespace
TEST(ResetterTest, All) {
- scoped_ptr<int> x;
+ std::unique_ptr<int> x;
OutArgument(&Resetter(&x).lvalue());
EXPECT_EQ(*x, 10);
}
diff --git a/brillo/process.cc b/brillo/process.cc
index 2700532..7af8fbb 100644
--- a/brillo/process.cc
+++ b/brillo/process.cc
@@ -13,9 +13,11 @@
#include <unistd.h>
#include <map>
+#include <memory>
#include <base/files/file_util.h>
#include <base/logging.h>
+#include <base/memory/ptr_util.h>
#include <base/posix/eintr_wrapper.h>
#include <base/process/process_metrics.h>
#include <base/strings/string_number_conversions.h>
@@ -209,7 +211,8 @@
if (arguments_.empty()) {
return false;
}
- scoped_ptr<char*[]> argv(new char*[arguments_.size() + 1]);
+ std::unique_ptr<char* []> argv =
+ base::MakeUnique<char* []>(arguments_.size() + 1);
for (size_t i = 0; i < arguments_.size(); ++i)
argv[i] = const_cast<char*>(arguments_[i].c_str());
diff --git a/libbrillo-381699.gypi b/libbrillo-395517.gypi
similarity index 75%
rename from libbrillo-381699.gypi
rename to libbrillo-395517.gypi
index c36aaf5..a846c70 100644
--- a/libbrillo-381699.gypi
+++ b/libbrillo-395517.gypi
@@ -1,6 +1,6 @@
{
'variables': {
- 'libbase_ver': 381699,
+ 'libbase_ver': 395517,
},
'includes': [
'../libbrillo/libbrillo.gypi',
diff --git a/libbrillo.gyp b/libbrillo.gyp
index 14fc874..487e99d 100644
--- a/libbrillo.gyp
+++ b/libbrillo.gyp
@@ -1,6 +1,6 @@
{
'includes': [
- 'libbrillo-381699.gypi',
+ 'libbrillo-395517.gypi',
'libpolicy.gypi',
]
}
diff --git a/policy/libpolicy.h b/policy/libpolicy.h
index c916305..eeca189 100644
--- a/policy/libpolicy.h
+++ b/policy/libpolicy.h
@@ -5,10 +5,10 @@
#ifndef LIBBRILLO_POLICY_LIBPOLICY_H_
#define LIBBRILLO_POLICY_LIBPOLICY_H_
+#include <memory>
#include <string>
#include <base/macros.h>
-#include <base/memory/scoped_ptr.h>
#pragma GCC visibility push(default)
@@ -38,7 +38,7 @@
virtual const DevicePolicy& GetDevicePolicy() const;
private:
- scoped_ptr<DevicePolicy> device_policy_;
+ std::unique_ptr<DevicePolicy> device_policy_;
bool device_policy_is_loaded_;
DISALLOW_COPY_AND_ASSIGN(PolicyProvider);