OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/feedback/feedback_data.h" | 5 #include "components/feedback/feedback_data.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 ++pending_op_count_; | 53 ++pending_op_count_; |
54 if (!manager || | 54 if (!manager || |
55 !manager->GetTraceData( | 55 !manager->GetTraceData( |
56 trace_id_, | 56 trace_id_, |
57 base::Bind(&FeedbackData::OnGetTraceData, this, trace_id_))) { | 57 base::Bind(&FeedbackData::OnGetTraceData, this, trace_id_))) { |
58 pending_op_count_--; | 58 pending_op_count_--; |
59 trace_id_ = 0; | 59 trace_id_ = 0; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 if (sys_info.get()) { | 63 if (sys_info) { |
64 ++pending_op_count_; | 64 ++pending_op_count_; |
65 AddLogs(std::move(sys_info)); | 65 AddLogs(std::move(sys_info)); |
66 BrowserThread::PostBlockingPoolTaskAndReply( | 66 BrowserThread::PostBlockingPoolTaskAndReply( |
67 FROM_HERE, | 67 FROM_HERE, base::Bind(&FeedbackData::CompressLogs, this), |
68 base::Bind(&FeedbackCommon::CompressLogs, this), | |
69 base::Bind(&FeedbackData::OnCompressComplete, this)); | 68 base::Bind(&FeedbackData::OnCompressComplete, this)); |
70 } | 69 } |
71 } | 70 } |
72 | 71 |
73 void FeedbackData::SetAndCompressHistograms( | 72 void FeedbackData::SetAndCompressHistograms( |
74 std::unique_ptr<std::string> histograms) { | 73 std::unique_ptr<std::string> histograms) { |
75 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 74 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
76 | 75 |
77 if (!histograms.get()) | 76 if (!histograms) |
78 return; | 77 return; |
79 ++pending_op_count_; | 78 ++pending_op_count_; |
80 BrowserThread::PostBlockingPoolTaskAndReply( | 79 BrowserThread::PostBlockingPoolTaskAndReply( |
81 FROM_HERE, | 80 FROM_HERE, |
82 base::Bind(&FeedbackCommon::CompressFile, | 81 base::Bind(&FeedbackData::CompressFile, this, |
83 this, | 82 base::FilePath(kHistogramsFilename), kHistogramsAttachmentName, |
84 base::FilePath(kHistogramsFilename), | |
85 kHistogramsAttachmentName, | |
86 base::Passed(&histograms)), | 83 base::Passed(&histograms)), |
87 base::Bind(&FeedbackData::OnCompressComplete, this)); | 84 base::Bind(&FeedbackData::OnCompressComplete, this)); |
88 } | 85 } |
89 | 86 |
90 void FeedbackData::AttachAndCompressFileData( | 87 void FeedbackData::AttachAndCompressFileData( |
91 std::unique_ptr<std::string> attached_filedata) { | 88 std::unique_ptr<std::string> attached_filedata) { |
92 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 89 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
93 | 90 |
94 if (!attached_filedata.get() || attached_filedata->empty()) | 91 if (!attached_filedata || attached_filedata->empty()) |
95 return; | 92 return; |
96 ++pending_op_count_; | 93 ++pending_op_count_; |
97 base::FilePath attached_file = | 94 base::FilePath attached_file = |
98 base::FilePath::FromUTF8Unsafe(attached_filename_); | 95 base::FilePath::FromUTF8Unsafe(attached_filename_); |
99 BrowserThread::PostBlockingPoolTaskAndReply( | 96 BrowserThread::PostBlockingPoolTaskAndReply( |
100 FROM_HERE, | 97 FROM_HERE, base::Bind(&FeedbackData::CompressFile, this, attached_file, |
101 base::Bind(&FeedbackCommon::CompressFile, | 98 std::string(), base::Passed(&attached_filedata)), |
102 this, | |
103 attached_file, | |
104 std::string(), | |
105 base::Passed(&attached_filedata)), | |
106 base::Bind(&FeedbackData::OnCompressComplete, this)); | 99 base::Bind(&FeedbackData::OnCompressComplete, this)); |
107 } | 100 } |
108 | 101 |
109 void FeedbackData::OnGetTraceData( | 102 void FeedbackData::OnGetTraceData( |
110 int trace_id, | 103 int trace_id, |
111 scoped_refptr<base::RefCountedString> trace_data) { | 104 scoped_refptr<base::RefCountedString> trace_data) { |
112 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 105 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
113 TracingManager* manager = TracingManager::Get(); | 106 TracingManager* manager = TracingManager::Get(); |
114 if (manager) | 107 if (manager) |
115 manager->DiscardTraceData(trace_id); | 108 manager->DiscardTraceData(trace_id); |
(...skipping 21 matching lines...) Expand all Loading... |
137 | 130 |
138 void FeedbackData::SendReport() { | 131 void FeedbackData::SendReport() { |
139 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 132 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
140 if (IsDataComplete() && !report_sent_) { | 133 if (IsDataComplete() && !report_sent_) { |
141 report_sent_ = true; | 134 report_sent_ = true; |
142 send_report_.Run(this); | 135 send_report_.Run(this); |
143 } | 136 } |
144 } | 137 } |
145 | 138 |
146 } // namespace feedback | 139 } // namespace feedback |
OLD | NEW |