mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-26 23:01:05 +08:00
minidump: Use the crashpad::internal namespace more appropriately.
MinidumpLocationDescriptorListWriter and MinidumpRVAListWriter are implementation details and should be in the crashpad::internal namespace. MinidumpUTF16StringListWriter and MinidumpUTF8StringListWriter are accessible to outside code and should not be in this namespace. TEST=minidump_test R=rsesek@chromium.org Review URL: https://codereview.chromium.org/699313007
This commit is contained in:
parent
4a22225fc0
commit
9386a054e2
@ -19,6 +19,7 @@
|
||||
#include "util/numeric/safe_assignment.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace internal {
|
||||
|
||||
MinidumpLocationDescriptorListWriter::MinidumpLocationDescriptorListWriter()
|
||||
: MinidumpWritable(),
|
||||
@ -31,7 +32,7 @@ MinidumpLocationDescriptorListWriter::~MinidumpLocationDescriptorListWriter() {
|
||||
}
|
||||
|
||||
void MinidumpLocationDescriptorListWriter::AddChild(
|
||||
scoped_ptr<internal::MinidumpWritable> child) {
|
||||
scoped_ptr<MinidumpWritable> child) {
|
||||
DCHECK_EQ(state(), kStateMutable);
|
||||
|
||||
children_.push_back(child.release());
|
||||
@ -67,7 +68,7 @@ size_t MinidumpLocationDescriptorListWriter::SizeOfObject() {
|
||||
children_.size() * sizeof(MINIDUMP_LOCATION_DESCRIPTOR);
|
||||
}
|
||||
|
||||
std::vector<internal::MinidumpWritable*>
|
||||
std::vector<MinidumpWritable*>
|
||||
MinidumpLocationDescriptorListWriter::Children() {
|
||||
DCHECK_GE(state(), kStateFrozen);
|
||||
|
||||
@ -99,4 +100,5 @@ bool MinidumpLocationDescriptorListWriter::WriteObject(
|
||||
return file_writer->WriteIoVec(&iovecs);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
@ -27,24 +27,24 @@
|
||||
#include "util/stdlib/pointer_container.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace internal {
|
||||
|
||||
//! \brief The writer for a MinidumpLocationDescriptorList object in a minidump
|
||||
//! file, containing a list of MINIDUMP_LOCATION_DESCRIPTOR objects.
|
||||
class MinidumpLocationDescriptorListWriter : public internal::MinidumpWritable {
|
||||
class MinidumpLocationDescriptorListWriter : public MinidumpWritable {
|
||||
protected:
|
||||
MinidumpLocationDescriptorListWriter();
|
||||
~MinidumpLocationDescriptorListWriter() override;
|
||||
|
||||
//! \brief Adds a MINIDUMP_LOCATION_DESCRIPTOR referencing an
|
||||
//! internal::MinidumpWritable to the MinidumpLocationDescriptorList.
|
||||
//! \brief Adds a MINIDUMP_LOCATION_DESCRIPTOR referencing a MinidumpWritable
|
||||
//! to the MinidumpLocationDescriptorList.
|
||||
//!
|
||||
//! This object takes ownership of \a child and becomes its parent in the
|
||||
//! overall tree of internal::MinidumpWritable objects.
|
||||
//! overall tree of MinidumpWritable objects.
|
||||
//!
|
||||
//! To provide type-correctness, subclasses are expected to provide a public
|
||||
//! method that accepts a `scoped_ptr`-wrapped argument of the proper
|
||||
//! internal::MinidumpWritable subclass, and call this method with that
|
||||
//! argument.
|
||||
//! MinidumpWritable subclass, and call this method with that argument.
|
||||
//!
|
||||
//! \note Valid in #kStateMutable.
|
||||
void AddChild(scoped_ptr<MinidumpWritable> child);
|
||||
@ -77,6 +77,7 @@ class MinidumpLocationDescriptorListWriter : public internal::MinidumpWritable {
|
||||
DISALLOW_COPY_AND_ASSIGN(MinidumpLocationDescriptorListWriter);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_MINIDUMP_LOCATION_DESCRIPTOR_LIST_WRITER_H_
|
||||
|
@ -25,7 +25,7 @@ namespace test {
|
||||
namespace {
|
||||
|
||||
class TestMinidumpLocationDescriptorListWriter final
|
||||
: public MinidumpLocationDescriptorListWriter {
|
||||
: public internal::MinidumpLocationDescriptorListWriter {
|
||||
public:
|
||||
TestMinidumpLocationDescriptorListWriter()
|
||||
: MinidumpLocationDescriptorListWriter() {
|
||||
|
@ -48,8 +48,7 @@ void MinidumpModuleCrashpadInfoWriter::InitializeFromSnapshot(
|
||||
}
|
||||
SetMinidumpModuleListIndex(module_list_index_u32);
|
||||
|
||||
auto list_annotations =
|
||||
make_scoped_ptr(new internal::MinidumpUTF8StringListWriter());
|
||||
auto list_annotations = make_scoped_ptr(new MinidumpUTF8StringListWriter());
|
||||
list_annotations->InitializeFromVector(module_snapshot->AnnotationsVector());
|
||||
if (list_annotations->IsUseful()) {
|
||||
SetListAnnotations(list_annotations.Pass());
|
||||
@ -65,7 +64,7 @@ void MinidumpModuleCrashpadInfoWriter::InitializeFromSnapshot(
|
||||
}
|
||||
|
||||
void MinidumpModuleCrashpadInfoWriter::SetListAnnotations(
|
||||
scoped_ptr<internal::MinidumpUTF8StringListWriter> list_annotations) {
|
||||
scoped_ptr<MinidumpUTF8StringListWriter> list_annotations) {
|
||||
DCHECK_EQ(state(), kStateMutable);
|
||||
|
||||
list_annotations_ = list_annotations.Pass();
|
||||
|
@ -72,7 +72,7 @@ class MinidumpModuleCrashpadInfoWriter final
|
||||
//!
|
||||
//! \note Valid in #kStateMutable.
|
||||
void SetListAnnotations(
|
||||
scoped_ptr<internal::MinidumpUTF8StringListWriter> list_annotations);
|
||||
scoped_ptr<MinidumpUTF8StringListWriter> list_annotations);
|
||||
|
||||
//! \brief Arranges for MinidumpModuleCrashpadInfo::simple_annotations to
|
||||
//! point to the MinidumpSimpleStringDictionaryWriter object to be written
|
||||
@ -103,7 +103,7 @@ class MinidumpModuleCrashpadInfoWriter final
|
||||
|
||||
private:
|
||||
MinidumpModuleCrashpadInfo module_;
|
||||
scoped_ptr<internal::MinidumpUTF8StringListWriter> list_annotations_;
|
||||
scoped_ptr<MinidumpUTF8StringListWriter> list_annotations_;
|
||||
scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter);
|
||||
@ -112,7 +112,7 @@ class MinidumpModuleCrashpadInfoWriter final
|
||||
//! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump
|
||||
//! file, containing a list of MinidumpModuleCrashpadInfo objects.
|
||||
class MinidumpModuleCrashpadInfoListWriter final
|
||||
: public MinidumpLocationDescriptorListWriter {
|
||||
: public internal::MinidumpLocationDescriptorListWriter {
|
||||
public:
|
||||
MinidumpModuleCrashpadInfoListWriter();
|
||||
~MinidumpModuleCrashpadInfoListWriter() override;
|
||||
|
@ -93,8 +93,7 @@ TEST(MinidumpModuleCrashpadInfoWriter, FullModule) {
|
||||
auto module_writer =
|
||||
make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
|
||||
module_writer->SetMinidumpModuleListIndex(kMinidumpModuleListIndex);
|
||||
auto string_list_writer =
|
||||
make_scoped_ptr(new internal::MinidumpUTF8StringListWriter());
|
||||
auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter());
|
||||
string_list_writer->InitializeFromVector(vector);
|
||||
module_writer->SetListAnnotations(string_list_writer.Pass());
|
||||
auto simple_string_dictionary_writer =
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "util/numeric/safe_assignment.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace internal {
|
||||
|
||||
MinidumpRVAListWriter::MinidumpRVAListWriter()
|
||||
: MinidumpWritable(),
|
||||
@ -30,8 +31,7 @@ MinidumpRVAListWriter::MinidumpRVAListWriter()
|
||||
MinidumpRVAListWriter::~MinidumpRVAListWriter() {
|
||||
}
|
||||
|
||||
void MinidumpRVAListWriter::AddChild(
|
||||
scoped_ptr<internal::MinidumpWritable> child) {
|
||||
void MinidumpRVAListWriter::AddChild(scoped_ptr<MinidumpWritable> child) {
|
||||
DCHECK_EQ(state(), kStateMutable);
|
||||
|
||||
children_.push_back(child.release());
|
||||
@ -65,7 +65,7 @@ size_t MinidumpRVAListWriter::SizeOfObject() {
|
||||
return sizeof(rva_list_base_) + children_.size() * sizeof(RVA);
|
||||
}
|
||||
|
||||
std::vector<internal::MinidumpWritable*> MinidumpRVAListWriter::Children() {
|
||||
std::vector<MinidumpWritable*> MinidumpRVAListWriter::Children() {
|
||||
DCHECK_GE(state(), kStateFrozen);
|
||||
|
||||
std::vector<MinidumpWritable*> children;
|
||||
@ -94,4 +94,5 @@ bool MinidumpRVAListWriter::WriteObject(FileWriterInterface* file_writer) {
|
||||
return file_writer->WriteIoVec(&iovecs);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
@ -27,24 +27,24 @@
|
||||
#include "util/stdlib/pointer_container.h"
|
||||
|
||||
namespace crashpad {
|
||||
namespace internal {
|
||||
|
||||
//! \brief The writer for a MinidumpRVAList object in a minidump file,
|
||||
//! containing a list of ::RVA pointers.
|
||||
class MinidumpRVAListWriter : public internal::MinidumpWritable {
|
||||
class MinidumpRVAListWriter : public MinidumpWritable {
|
||||
protected:
|
||||
MinidumpRVAListWriter();
|
||||
~MinidumpRVAListWriter() override;
|
||||
|
||||
//! \brief Adds an ::RVA referencing an internal::MinidumpWritable to the
|
||||
//! \brief Adds an ::RVA referencing an MinidumpWritable to the
|
||||
//! MinidumpRVAList.
|
||||
//!
|
||||
//! This object takes ownership of \a child and becomes its parent in the
|
||||
//! overall tree of internal::MinidumpWritable objects.
|
||||
//! overall tree of MinidumpWritable objects.
|
||||
//!
|
||||
//! To provide type-correctness, subclasses are expected to provide a public
|
||||
//! method that accepts a `scoped_ptr`-wrapped argument of the proper
|
||||
//! internal::MinidumpWritable subclass, and call this method with that
|
||||
//! argument.
|
||||
//! MinidumpWritable subclass, and call this method with that argument.
|
||||
//!
|
||||
//! \note Valid in #kStateMutable.
|
||||
void AddChild(scoped_ptr<MinidumpWritable> child);
|
||||
@ -73,6 +73,7 @@ class MinidumpRVAListWriter : public internal::MinidumpWritable {
|
||||
DISALLOW_COPY_AND_ASSIGN(MinidumpRVAListWriter);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_MINIDUMP_RVA_LIST_WRITER_H_
|
||||
|
@ -24,7 +24,7 @@ namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
||||
class TestMinidumpRVAListWriter final : public MinidumpRVAListWriter {
|
||||
class TestMinidumpRVAListWriter final : public internal::MinidumpRVAListWriter {
|
||||
public:
|
||||
TestMinidumpRVAListWriter() : MinidumpRVAListWriter() {}
|
||||
~TestMinidumpRVAListWriter() override {}
|
||||
|
@ -95,17 +95,18 @@ void MinidumpUTF16StringWriter::SetUTF8(const std::string& string_utf8) {
|
||||
MinidumpUTF8StringWriter::~MinidumpUTF8StringWriter() {
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
MinidumpStringListWriter<Traits>::MinidumpStringListWriter()
|
||||
template <typename MinidumpStringWriterType>
|
||||
MinidumpStringListWriter<MinidumpStringWriterType>::MinidumpStringListWriter()
|
||||
: MinidumpRVAListWriter() {
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
MinidumpStringListWriter<Traits>::~MinidumpStringListWriter() {
|
||||
template <typename MinidumpStringWriterType>
|
||||
MinidumpStringListWriter<
|
||||
MinidumpStringWriterType>::~MinidumpStringListWriter() {
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
void MinidumpStringListWriter<Traits>::InitializeFromVector(
|
||||
template <typename MinidumpStringWriterType>
|
||||
void MinidumpStringListWriter<MinidumpStringWriterType>::InitializeFromVector(
|
||||
const std::vector<std::string>& vector) {
|
||||
DCHECK_EQ(state(), kStateMutable);
|
||||
DCHECK(IsEmpty());
|
||||
@ -115,23 +116,23 @@ void MinidumpStringListWriter<Traits>::InitializeFromVector(
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
void MinidumpStringListWriter<Traits>::AddStringUTF8(
|
||||
template <typename MinidumpStringWriterType>
|
||||
void MinidumpStringListWriter<MinidumpStringWriterType>::AddStringUTF8(
|
||||
const std::string& string_utf8) {
|
||||
auto string_writer = make_scoped_ptr(new MinidumpStringWriterType());
|
||||
string_writer->SetUTF8(string_utf8);
|
||||
AddChild(string_writer.Pass());
|
||||
}
|
||||
|
||||
template <typename Traits>
|
||||
bool MinidumpStringListWriter<Traits>::IsUseful() const {
|
||||
template <typename MinidumpStringWriterType>
|
||||
bool MinidumpStringListWriter<MinidumpStringWriterType>::IsUseful() const {
|
||||
return !IsEmpty();
|
||||
}
|
||||
|
||||
// Explicit template instantiation of the forms of MinidumpStringListWriter<>
|
||||
// used as type aliases.
|
||||
template class MinidumpStringListWriter<MinidumpStringListWriterUTF16Traits>;
|
||||
template class MinidumpStringListWriter<MinidumpStringListWriterUTF8Traits>;
|
||||
template class MinidumpStringListWriter<MinidumpUTF16StringWriter>;
|
||||
template class MinidumpStringListWriter<MinidumpUTF8StringWriter>;
|
||||
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
@ -126,25 +126,11 @@ class MinidumpUTF8StringWriter final
|
||||
DISALLOW_COPY_AND_ASSIGN(MinidumpUTF8StringWriter);
|
||||
};
|
||||
|
||||
//! \cond
|
||||
|
||||
struct MinidumpStringListWriterUTF16Traits {
|
||||
using MinidumpStringWriterType = MinidumpUTF16StringWriter;
|
||||
};
|
||||
|
||||
struct MinidumpStringListWriterUTF8Traits {
|
||||
using MinidumpStringWriterType = MinidumpUTF8StringWriter;
|
||||
};
|
||||
|
||||
//! \endcond
|
||||
|
||||
//! \brief The writer for a MinidumpRVAList object in a minidump file,
|
||||
//! containing a list of \a Traits::MinidumpStringWriterType objects.
|
||||
template <typename Traits>
|
||||
class MinidumpStringListWriter : public MinidumpRVAListWriter {
|
||||
//! containing a list of \a MinidumpStringWriterType objects.
|
||||
template <typename MinidumpStringWriterType>
|
||||
class MinidumpStringListWriter final : public MinidumpRVAListWriter {
|
||||
public:
|
||||
using MinidumpStringWriterType = typename Traits::MinidumpStringWriterType;
|
||||
|
||||
MinidumpStringListWriter();
|
||||
~MinidumpStringListWriter() override;
|
||||
|
||||
@ -165,7 +151,7 @@ class MinidumpStringListWriter : public MinidumpRVAListWriter {
|
||||
//!
|
||||
//! This object creates a new string writer with string value \a string_utf8,
|
||||
//! takes ownership of it, and becomes its parent in the overall tree of
|
||||
//! internal::MinidumpWritable objects.
|
||||
//! MinidumpWritable objects.
|
||||
//!
|
||||
//! \note Valid in #kStateMutable.
|
||||
void AddStringUTF8(const std::string& string_utf8);
|
||||
@ -183,12 +169,13 @@ class MinidumpStringListWriter : public MinidumpRVAListWriter {
|
||||
DISALLOW_COPY_AND_ASSIGN(MinidumpStringListWriter);
|
||||
};
|
||||
|
||||
using MinidumpUTF16StringListWriter =
|
||||
MinidumpStringListWriter<MinidumpStringListWriterUTF16Traits>;
|
||||
using MinidumpUTF8StringListWriter =
|
||||
MinidumpStringListWriter<MinidumpStringListWriterUTF8Traits>;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
using MinidumpUTF16StringListWriter = internal::MinidumpStringListWriter<
|
||||
internal::MinidumpUTF16StringWriter>;
|
||||
using MinidumpUTF8StringListWriter = internal::MinidumpStringListWriter<
|
||||
internal::MinidumpUTF8StringWriter>;
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_MINIDUMP_MINIDUMP_STRING_WRITER_H_
|
||||
|
@ -198,7 +198,7 @@ TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) {
|
||||
}
|
||||
|
||||
struct MinidumpUTF16StringListWriterTraits {
|
||||
using MinidumpStringListWriterType = internal::MinidumpUTF16StringListWriter;
|
||||
using MinidumpStringListWriterType = MinidumpUTF16StringListWriter;
|
||||
static string16 ExpectationForUTF8(const std::string& utf8) {
|
||||
return base::UTF8ToUTF16(utf8);
|
||||
}
|
||||
@ -208,7 +208,7 @@ struct MinidumpUTF16StringListWriterTraits {
|
||||
};
|
||||
|
||||
struct MinidumpUTF8StringListWriterTraits {
|
||||
using MinidumpStringListWriterType = internal::MinidumpUTF8StringListWriter;
|
||||
using MinidumpStringListWriterType = MinidumpUTF8StringListWriter;
|
||||
static std::string ExpectationForUTF8(const std::string& utf8) {
|
||||
return utf8;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user