OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/feedback_private/feedback_service.h" | 5 #include "chrome/browser/extensions/api/feedback_private/feedback_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 base::Bind(&FeedbackService::ScreenshotCallback, | 66 base::Bind(&FeedbackService::ScreenshotCallback, |
67 GetWeakPtr())); | 67 GetWeakPtr())); |
68 screenshot_reader->Start(); | 68 screenshot_reader->Start(); |
69 } | 69 } |
70 | 70 |
71 CompleteSendFeedback(); | 71 CompleteSendFeedback(); |
72 } | 72 } |
73 | 73 |
74 void FeedbackService::AttachedFileCallback(scoped_ptr<std::string> data, | 74 void FeedbackService::AttachedFileCallback(scoped_ptr<std::string> data, |
75 int64 /* total_blob_length */) { | 75 int64 /* total_blob_length */) { |
76 if (!data.get()) | 76 feedback_data_->set_attached_file_uuid(std::string()); |
77 feedback_data_->set_attached_file_uuid(std::string()); | 77 if (data) |
78 else | |
79 feedback_data_->AttachAndCompressFileData(data.Pass()); | 78 feedback_data_->AttachAndCompressFileData(data.Pass()); |
80 | 79 |
81 CompleteSendFeedback(); | 80 CompleteSendFeedback(); |
82 } | 81 } |
83 | 82 |
84 void FeedbackService::ScreenshotCallback(scoped_ptr<std::string> data, | 83 void FeedbackService::ScreenshotCallback(scoped_ptr<std::string> data, |
85 int64 /* total_blob_length */) { | 84 int64 /* total_blob_length */) { |
86 if (!data.get()) | 85 feedback_data_->set_screenshot_uuid(std::string()); |
87 feedback_data_->set_screenshot_uuid(std::string()); | 86 if (data) |
88 else | |
89 feedback_data_->set_image(data.Pass()); | 87 feedback_data_->set_image(data.Pass()); |
90 | 88 |
91 CompleteSendFeedback(); | 89 CompleteSendFeedback(); |
92 } | 90 } |
93 | 91 |
94 void FeedbackService::GetSystemInformation( | 92 void FeedbackService::GetSystemInformation( |
95 const GetSystemInformationCallback& callback) { | 93 const GetSystemInformationCallback& callback) { |
96 system_information_callback_ = callback; | 94 system_information_callback_ = callback; |
97 | 95 |
98 system_logs::ScrubbedSystemLogsFetcher* fetcher = | 96 system_logs::ScrubbedSystemLogsFetcher* fetcher = |
(...skipping 19 matching lines...) Expand all Loading... |
118 } | 116 } |
119 | 117 |
120 void FeedbackService::CompleteSendFeedback() { | 118 void FeedbackService::CompleteSendFeedback() { |
121 // A particular data collection is considered completed if, | 119 // A particular data collection is considered completed if, |
122 // a.) The blob URL is invalid - this will either happen because we never had | 120 // a.) The blob URL is invalid - this will either happen because we never had |
123 // a URL and never needed to read this data, or that the data read failed | 121 // a URL and never needed to read this data, or that the data read failed |
124 // and we set it to invalid in the data read callback. | 122 // and we set it to invalid in the data read callback. |
125 // b.) The associated data object exists, meaning that the data has been read | 123 // b.) The associated data object exists, meaning that the data has been read |
126 // and the read callback has updated the associated data on the feedback | 124 // and the read callback has updated the associated data on the feedback |
127 // object. | 125 // object. |
128 bool attached_file_completed = | 126 bool attached_file_completed = feedback_data_->attached_file_uuid().empty(); |
129 feedback_data_->attached_file_uuid().empty() || | 127 bool screenshot_completed = feedback_data_->screenshot_uuid().empty(); |
130 feedback_data_->attached_filedata(); | |
131 bool screenshot_completed = | |
132 feedback_data_->screenshot_uuid().empty() || | |
133 feedback_data_->image(); | |
134 | 128 |
135 if (screenshot_completed && attached_file_completed) { | 129 if (screenshot_completed && attached_file_completed) { |
136 // Signal the feedback object that the data from the feedback page has been | 130 // Signal the feedback object that the data from the feedback page has been |
137 // filled - the object will manage sending of the actual report. | 131 // filled - the object will manage sending of the actual report. |
138 feedback_data_->OnFeedbackPageDataComplete(); | 132 feedback_data_->OnFeedbackPageDataComplete(); |
139 // TODO(rkc): Change this once we have FeedbackData/Util refactored to | 133 // TODO(rkc): Change this once we have FeedbackData/Util refactored to |
140 // report the status of the report being sent. | 134 // report the status of the report being sent. |
141 send_feedback_callback_.Run(true); | 135 send_feedback_callback_.Run(true); |
142 } | 136 } |
143 } | 137 } |
144 | 138 |
145 } // namespace extensions | 139 } // namespace extensions |
OLD | NEW |