summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/tracked.cc6
-rw-r--r--base/tracked.h2
-rw-r--r--chrome/browser/sync/js/js_transaction_observer.cc16
-rw-r--r--chrome/browser/sync/util/weak_handle.cc15
4 files changed, 12 insertions, 27 deletions
diff --git a/base/tracked.cc b/base/tracked.cc
index 124e721..517591b 100644
--- a/base/tracked.cc
+++ b/base/tracked.cc
@@ -13,6 +13,7 @@ void* _ReturnAddress();
#include "base/tracked.h"
+#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
#include "base/tracked_objects.h"
@@ -39,6 +40,11 @@ Location::Location()
program_counter_(NULL) {
}
+std::string Location::ToString() const {
+ return std::string(function_name_) + "@" + file_name_ + ":" +
+ base::IntToString(line_number_);
+}
+
void Location::Write(bool display_filename, bool display_function_name,
std::string* output) const {
base::StringAppendF(output, "%s[%d] ",
diff --git a/base/tracked.h b/base/tracked.h
index 3c73519..337f3e0 100644
--- a/base/tracked.h
+++ b/base/tracked.h
@@ -68,6 +68,8 @@ class BASE_EXPORT Location {
int line_number() const { return line_number_; }
const void* program_counter() const { return program_counter_; }
+ std::string ToString() const;
+
void Write(bool display_filename, bool display_function_name,
std::string* output) const;
diff --git a/chrome/browser/sync/js/js_transaction_observer.cc b/chrome/browser/sync/js/js_transaction_observer.cc
index 9a6d0aa..c0d5b62 100644
--- a/chrome/browser/sync/js/js_transaction_observer.cc
+++ b/chrome/browser/sync/js/js_transaction_observer.cc
@@ -26,16 +26,6 @@ void JsTransactionObserver::SetJsEventHandler(
event_handler_ = event_handler;
}
-namespace {
-
-std::string GetLocationString(const tracked_objects::Location& location) {
- return std::string(location.function_name()) + "@" +
- location.file_name() + ":" +
- base::IntToString(location.line_number());
-}
-
-} // namespace
-
void JsTransactionObserver::OnTransactionStart(
const tracked_objects::Location& location,
const syncable::WriterTag& writer) {
@@ -44,7 +34,7 @@ void JsTransactionObserver::OnTransactionStart(
return;
}
DictionaryValue details;
- details.SetString("location", GetLocationString(location));
+ details.SetString("location", location.ToString());
details.SetString("writer", syncable::WriterTagToString(writer));
HandleJsEvent(FROM_HERE, "onTransactionStart", JsEventDetails(&details));
}
@@ -67,7 +57,7 @@ void JsTransactionObserver::OnTransactionMutate(
return;
}
DictionaryValue details;
- details.SetString("location", GetLocationString(location));
+ details.SetString("location", location.ToString());
details.SetString("writer", syncable::WriterTagToString(writer));
Value* mutations_value = NULL;
const size_t mutations_size = mutations.Get().size();
@@ -93,7 +83,7 @@ void JsTransactionObserver::OnTransactionEnd(
return;
}
DictionaryValue details;
- details.SetString("location", GetLocationString(location));
+ details.SetString("location", location.ToString());
details.SetString("writer", syncable::WriterTagToString(writer));
HandleJsEvent(FROM_HERE, "onTransactionEnd", JsEventDetails(&details));
}
diff --git a/chrome/browser/sync/util/weak_handle.cc b/chrome/browser/sync/util/weak_handle.cc
index c4e5969..71acad6 100644
--- a/chrome/browser/sync/util/weak_handle.cc
+++ b/chrome/browser/sync/util/weak_handle.cc
@@ -22,24 +22,11 @@ bool WeakHandleCoreBase::IsOnOwnerThread() const {
WeakHandleCoreBase::~WeakHandleCoreBase() {}
-namespace {
-
-// TODO(akalin): Merge with similar function in
-// js_transaction_observer.cc.
-std::string GetLocationString(const tracked_objects::Location& location) {
- std::ostringstream oss;
- oss << location.function_name() << "@"
- << location.file_name() << ":" << location.line_number();
- return oss.str();
-}
-
-} // namespace
-
void WeakHandleCoreBase::PostToOwnerThread(
const tracked_objects::Location& from_here,
const base::Closure& fn) const {
if (!owner_loop_proxy_->PostTask(from_here, fn)) {
- VLOG(1) << "Could not post task from " << GetLocationString(from_here);
+ VLOG(1) << "Could not post task from " << from_here.ToString();
}
}