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" |
11 #include "base/json/json_string_value_serializer.h" | 11 #include "base/json/json_string_value_serializer.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/task_scheduler/post_task.h" | |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "components/feedback/feedback_util.h" | 17 #include "components/feedback/feedback_util.h" |
17 #include "components/feedback/tracing_manager.h" | 18 #include "components/feedback/tracing_manager.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 | 20 |
20 using content::BrowserThread; | 21 using content::BrowserThread; |
21 | 22 |
22 namespace feedback { | 23 namespace feedback { |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 trace_id_, | 57 trace_id_, |
57 base::Bind(&FeedbackData::OnGetTraceData, this, trace_id_))) { | 58 base::Bind(&FeedbackData::OnGetTraceData, this, trace_id_))) { |
58 pending_op_count_--; | 59 pending_op_count_--; |
59 trace_id_ = 0; | 60 trace_id_ = 0; |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 if (sys_info) { | 64 if (sys_info) { |
64 ++pending_op_count_; | 65 ++pending_op_count_; |
65 AddLogs(std::move(sys_info)); | 66 AddLogs(std::move(sys_info)); |
66 BrowserThread::PostBlockingPoolTaskAndReply( | 67 base::PostTaskWithTraitsAndReply( |
67 FROM_HERE, base::Bind(&FeedbackData::CompressLogs, this), | 68 FROM_HERE, |
69 base::TaskTraits().WithPriority(base::TaskPriority::BACKGROUND), | |
afakhry
2017/05/03 16:38:36
Why doesn't this have the .MayBlock() like the oth
fdoray
2017/05/03 16:41:30
Done.
| |
70 base::Bind(&FeedbackData::CompressLogs, this), | |
68 base::Bind(&FeedbackData::OnCompressComplete, this)); | 71 base::Bind(&FeedbackData::OnCompressComplete, this)); |
69 } | 72 } |
70 } | 73 } |
71 | 74 |
72 void FeedbackData::SetAndCompressHistograms( | 75 void FeedbackData::SetAndCompressHistograms( |
73 std::unique_ptr<std::string> histograms) { | 76 std::unique_ptr<std::string> histograms) { |
74 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 77 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
75 | 78 |
76 if (!histograms) | 79 if (!histograms) |
77 return; | 80 return; |
78 ++pending_op_count_; | 81 ++pending_op_count_; |
79 BrowserThread::PostBlockingPoolTaskAndReply( | 82 base::PostTaskWithTraitsAndReply( |
80 FROM_HERE, | 83 FROM_HERE, |
84 base::TaskTraits().MayBlock().WithPriority( | |
85 base::TaskPriority::BACKGROUND), | |
81 base::Bind(&FeedbackData::CompressFile, this, | 86 base::Bind(&FeedbackData::CompressFile, this, |
82 base::FilePath(kHistogramsFilename), kHistogramsAttachmentName, | 87 base::FilePath(kHistogramsFilename), kHistogramsAttachmentName, |
83 base::Passed(&histograms)), | 88 base::Passed(&histograms)), |
84 base::Bind(&FeedbackData::OnCompressComplete, this)); | 89 base::Bind(&FeedbackData::OnCompressComplete, this)); |
85 } | 90 } |
86 | 91 |
87 void FeedbackData::AttachAndCompressFileData( | 92 void FeedbackData::AttachAndCompressFileData( |
88 std::unique_ptr<std::string> attached_filedata) { | 93 std::unique_ptr<std::string> attached_filedata) { |
89 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 94 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
90 | 95 |
91 if (!attached_filedata || attached_filedata->empty()) | 96 if (!attached_filedata || attached_filedata->empty()) |
92 return; | 97 return; |
93 ++pending_op_count_; | 98 ++pending_op_count_; |
94 base::FilePath attached_file = | 99 base::FilePath attached_file = |
95 base::FilePath::FromUTF8Unsafe(attached_filename_); | 100 base::FilePath::FromUTF8Unsafe(attached_filename_); |
96 BrowserThread::PostBlockingPoolTaskAndReply( | 101 base::PostTaskWithTraitsAndReply( |
97 FROM_HERE, base::Bind(&FeedbackData::CompressFile, this, attached_file, | 102 FROM_HERE, |
98 std::string(), base::Passed(&attached_filedata)), | 103 base::TaskTraits().MayBlock().WithPriority( |
104 base::TaskPriority::BACKGROUND), | |
105 base::Bind(&FeedbackData::CompressFile, this, attached_file, | |
106 std::string(), base::Passed(&attached_filedata)), | |
99 base::Bind(&FeedbackData::OnCompressComplete, this)); | 107 base::Bind(&FeedbackData::OnCompressComplete, this)); |
100 } | 108 } |
101 | 109 |
102 void FeedbackData::OnGetTraceData( | 110 void FeedbackData::OnGetTraceData( |
103 int trace_id, | 111 int trace_id, |
104 scoped_refptr<base::RefCountedString> trace_data) { | 112 scoped_refptr<base::RefCountedString> trace_data) { |
105 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 113 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
106 TracingManager* manager = TracingManager::Get(); | 114 TracingManager* manager = TracingManager::Get(); |
107 if (manager) | 115 if (manager) |
108 manager->DiscardTraceData(trace_id); | 116 manager->DiscardTraceData(trace_id); |
(...skipping 21 matching lines...) Expand all Loading... | |
130 | 138 |
131 void FeedbackData::SendReport() { | 139 void FeedbackData::SendReport() { |
132 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 140 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
133 if (IsDataComplete() && !report_sent_) { | 141 if (IsDataComplete() && !report_sent_) { |
134 report_sent_ = true; | 142 report_sent_ = true; |
135 send_report_.Run(this); | 143 send_report_.Run(this); |
136 } | 144 } |
137 } | 145 } |
138 | 146 |
139 } // namespace feedback | 147 } // namespace feedback |
OLD | NEW |