Skip to content

Commit 058aa9a

Browse files
committed
[Breakpad]: 移除超时参数配置及相关功能
-**功能简化**: 移除Breakpad初始化时的超时参数配置,简化接口设计 -**接口变更**: 删除Breakpad构造函数中的timeout_ms参数和getTimeoutMs()方法 -**测试更新**: 同步更新单元测试用例,移除对超时参数的验证 -**示例更新**: 更新示例代码,移除超时参数的使用和相关输出
1 parent 348845f commit 058aa9a

File tree

4 files changed

+7
-31
lines changed

4 files changed

+7
-31
lines changed

src/Breakpad/breakpad.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class BreakpadPrivate
1818
{
1919
public:
20-
explicit BreakpadPrivate(const std::string &dump_path, int timeout_ms, Breakpad *q);
20+
explicit BreakpadPrivate(const std::string &dump_path, Breakpad *q);
2121
~BreakpadPrivate() = default;
2222

2323
bool initialize();
@@ -27,7 +27,6 @@ class BreakpadPrivate
2727
Breakpad *q_ptr;
2828

2929
std::string dumpPath;
30-
int timeoutMS;
3130
Breakpad::CrashCallback crashCallback;
3231
std::unique_ptr<google_breakpad::ExceptionHandler> handlerPtr;
3332
};
@@ -99,10 +98,9 @@ bool linuxCallback(const google_breakpad::MinidumpDescriptor &descriptor,
9998

10099
} // namespace
101100

102-
BreakpadPrivate::BreakpadPrivate(const std::string &dump_path, int timeout_ms, Breakpad *q)
101+
BreakpadPrivate::BreakpadPrivate(const std::string &dump_path, Breakpad *q)
103102
: q_ptr(q)
104103
, dumpPath(dump_path)
105-
, timeoutMS(timeout_ms)
106104
{
107105
if (!initialize()) {
108106
throw std::runtime_error("Failed to initialize Breakpad");
@@ -159,8 +157,8 @@ bool BreakpadPrivate::handleCrash(const std::string &dump_path, bool succeeded)
159157
return succeeded;
160158
}
161159

162-
Breakpad::Breakpad(const std::string &dump_path, int timeout_ms)
163-
: d_ptr(std::make_unique<BreakpadPrivate>(dump_path, timeout_ms, this))
160+
Breakpad::Breakpad(const std::string &dump_path)
161+
: d_ptr(std::make_unique<BreakpadPrivate>(dump_path, this))
164162
{}
165163

166164
Breakpad::~Breakpad() = default;
@@ -179,8 +177,3 @@ std::string Breakpad::getDumpPath() const
179177
{
180178
return d_ptr->dumpPath;
181179
}
182-
183-
int Breakpad::getTimeoutMs() const
184-
{
185-
return d_ptr->timeoutMS;
186-
}

src/Breakpad/breakpad.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ class Breakpad : noncopyable
1212
public:
1313
using CrashCallback = std::function<bool(const std::string &dump_path, bool succeeded)>;
1414

15-
explicit Breakpad(const std::string &dump_path, int timeout_ms = 5000);
15+
explicit Breakpad(const std::string &dump_path);
1616
~Breakpad();
1717

1818
void setCrashCallback(CrashCallback callback);
1919

2020
bool writeMinidump();
2121

2222
std::string getDumpPath() const;
23-
int getTimeoutMs() const;
2423

2524
private:
2625
std::unique_ptr<BreakpadPrivate> d_ptr;

src/Breakpad/breakpad_unittest.cc

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,12 @@ class BreakpadTest : public ::testing::Test
2828
std::string test_dump_path_;
2929
};
3030

31-
// 测试基本构造和析构
32-
TEST_F(BreakpadTest, ConstructionAndDestruction)
33-
{
34-
EXPECT_NO_THROW({ Breakpad breakpad(test_dump_path_); });
35-
36-
EXPECT_NO_THROW({
37-
Breakpad breakpad(test_dump_path_, 10000); // 带超时参数
38-
});
39-
}
40-
4131
// 测试获取配置信息
4232
TEST_F(BreakpadTest, GetConfiguration)
4333
{
44-
Breakpad breakpad(test_dump_path_, 8000);
34+
Breakpad breakpad(test_dump_path_);
4535

4636
EXPECT_EQ(breakpad.getDumpPath(), test_dump_path_);
47-
EXPECT_EQ(breakpad.getTimeoutMs(), 8000);
48-
49-
// 测试默认超时时间
50-
Breakpad breakpad_default(test_dump_path_);
51-
EXPECT_EQ(breakpad_default.getTimeoutMs(), 5000);
5237
}
5338

5439
// 测试设置回调函数

src/Breakpad/example.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
4646

4747
try {
4848
auto dumpPath = std::filesystem::current_path() / "crash_dumps";
49-
Breakpad breakpad(dumpPath.string(), 10000);
49+
Breakpad breakpad(dumpPath.string());
5050

5151
// 设置详细的崩溃回调
5252
breakpad.setCrashCallback([](const std::string &dump_path, bool success) {
@@ -66,7 +66,6 @@ int main(int argc, char *argv[])
6666

6767
std::cout << "Breakpad initialized successfully" << std::endl;
6868
std::cout << "Dump path: " << breakpad.getDumpPath() << std::endl;
69-
std::cout << "Timeout: " << breakpad.getTimeoutMs() << "ms" << std::endl;
7069

7170
// 解析命令行参数
7271
bool should_crash = false;

0 commit comments

Comments
 (0)