Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bug_report_data.h" | 5 #include "chrome/browser/bug_report_data.h" |
| 6 | 6 |
| 7 #include "chrome/browser/bug_report_util.h" | |
| 8 #include "content/browser/browser_thread.h" | |
| 9 | |
| 7 #if defined(OS_CHROMEOS) | 10 #if defined(OS_CHROMEOS) |
| 8 #include "chrome/browser/chromeos/notifications/system_notification.h" | 11 #include "chrome/browser/chromeos/notifications/system_notification.h" |
| 9 #endif | 12 #endif |
| 10 | 13 |
| 11 BugReportData::BugReportData() | 14 BugReportData::BugReportData() |
| 12 : profile_(NULL), | 15 : profile_(NULL), |
| 13 problem_type_(0) | 16 problem_type_(0) |
| 14 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
| 15 , sys_info_(NULL) | 18 , sys_info_(NULL) |
| 16 , zip_content_(NULL) | 19 , zip_content_(NULL) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 27 const int problem_type, | 30 const int problem_type, |
| 28 const std::string& page_url, | 31 const std::string& page_url, |
| 29 const std::string& description, | 32 const std::string& description, |
| 30 const std::vector<unsigned char>& image | 33 const std::vector<unsigned char>& image |
| 31 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 32 , const std::string& user_email | 35 , const std::string& user_email |
| 33 , const bool send_sys_info | 36 , const bool send_sys_info |
| 34 , const bool sent_report | 37 , const bool sent_report |
| 35 #endif | 38 #endif |
| 36 ) { | 39 ) { |
| 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 37 profile_ = profile; | 41 profile_ = profile; |
| 38 target_tab_url_ = target_tab_url; | 42 target_tab_url_ = target_tab_url; |
| 39 problem_type_ = problem_type; | 43 problem_type_ = problem_type; |
| 40 page_url_ = page_url; | 44 page_url_ = page_url; |
| 41 description_ = description; | 45 description_ = description; |
| 42 image_ = image; | 46 image_ = image; |
| 43 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
| 44 user_email_ = user_email; | 48 user_email_ = user_email; |
| 45 send_sys_info_ = send_sys_info; | 49 send_sys_info_ = send_sys_info; |
| 46 sent_report_ = sent_report; | 50 sent_report_ = sent_report; |
| 47 #endif | 51 #endif |
| 48 } | 52 } |
| 49 | 53 |
| 54 void BugReportData::SendReport() { | |
|
stevenjb
2011/08/03 01:55:20
Moved from bug_report_ui.cc
| |
| 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 56 #if defined(OS_CHROMEOS) | |
| 57 if (sent_report_) | |
| 58 return; // We already received the syslogs and sent the report. | |
| 59 | |
| 60 // Set send_report_ to ensure that we only send one report. | |
| 61 sent_report_ = true; | |
| 62 #endif | |
| 63 | |
| 64 int image_data_size = image_.size(); | |
| 65 char* image_data = image_data_size ? | |
| 66 reinterpret_cast<char*>(&(image_.front())) : NULL; | |
| 67 gfx::Rect& screen_size = BugReportUtil::GetScreenshotSize(); | |
| 68 BugReportUtil::SendReport(profile_ | |
| 69 , problem_type_ | |
| 70 , page_url_ | |
| 71 , description_ | |
| 72 , image_data | |
| 73 , image_data_size | |
| 74 , screen_size.width() | |
| 75 , screen_size.height() | |
| 76 #if defined(OS_CHROMEOS) | |
| 77 , user_email_ | |
| 78 , zip_content_ ? zip_content_->c_str() : NULL | |
| 79 , zip_content_ ? zip_content_->length() : 0 | |
| 80 , send_sys_info_ ? sys_info_ : NULL | |
| 81 #endif | |
| 82 ); | |
| 50 | 83 |
| 51 #if defined(OS_CHROMEOS) | 84 #if defined(OS_CHROMEOS) |
| 52 // Called from the same thread as HandleGetDialogDefaults, i.e. the UI thread. | 85 if (sys_info_) { |
|
James Cook
2011/08/03 17:06:49
Don't need to check if pointer is non-null, just c
stevenjb
2011/08/03 19:11:39
True, but since we are also setting variables to N
| |
| 86 delete sys_info_; | |
| 87 sys_info_ = NULL; | |
| 88 } | |
| 89 if (zip_content_) { | |
| 90 delete zip_content_; | |
| 91 zip_content_ = NULL; | |
| 92 } | |
| 93 #endif | |
| 94 | |
| 95 // Delete this object once the report has been sent. | |
| 96 delete this; | |
| 97 } | |
| 98 | |
| 99 #if defined(OS_CHROMEOS) | |
| 100 // SyslogsComplete may be called before UpdateData, in which case, we do not | |
| 101 // want to delete the logs that were gathered, and we do not want to send the | |
| 102 // report either. Instead simply populate |sys_info_| and |zip_content_|. | |
| 53 void BugReportData::SyslogsComplete(chromeos::system::LogDictionaryType* logs, | 103 void BugReportData::SyslogsComplete(chromeos::system::LogDictionaryType* logs, |
| 54 std::string* zip_content) { | 104 std::string* zip_content) { |
| 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 55 if (sent_report_) { | 106 if (sent_report_) { |
| 56 // We already sent the report, just delete the data. | 107 // We already sent the report, just delete the data. |
| 57 if (logs) | 108 if (logs) |
| 58 delete logs; | 109 delete logs; |
| 59 if (zip_content) | 110 if (zip_content) |
| 60 delete zip_content; | 111 delete zip_content; |
| 61 } else { | 112 } else { |
| 62 zip_content_ = zip_content; | 113 zip_content_ = zip_content; |
| 63 sys_info_ = logs; // Will get deleted when SendReport() is called. | 114 sys_info_ = logs; // Will get deleted when SendReport() is called. |
| 64 if (send_sys_info_) { | 115 if (send_sys_info_) { |
| 65 // We already prepared the report, send it now. | 116 // We already prepared the report, send it now. |
| 66 this->SendReport(); | 117 this->SendReport(); |
| 67 } | 118 } |
| 68 } | 119 } |
| 69 } | 120 } |
| 70 #endif | 121 #endif |
| OLD | NEW |