Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui.cc

Issue 375213002: net-internals: Fallback debug log store when non-native path is download target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/net_internals/net_internals_ui.h" 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "net/http/http_network_session.h" 72 #include "net/http/http_network_session.h"
73 #include "net/http/http_server_properties.h" 73 #include "net/http/http_server_properties.h"
74 #include "net/http/http_stream_factory.h" 74 #include "net/http/http_stream_factory.h"
75 #include "net/http/transport_security_state.h" 75 #include "net/http/transport_security_state.h"
76 #include "net/proxy/proxy_service.h" 76 #include "net/proxy/proxy_service.h"
77 #include "net/url_request/url_request_context.h" 77 #include "net/url_request/url_request_context.h"
78 #include "net/url_request/url_request_context_getter.h" 78 #include "net/url_request/url_request_context_getter.h"
79 #include "ui/base/resource/resource_bundle.h" 79 #include "ui/base/resource/resource_bundle.h"
80 80
81 #if defined(OS_CHROMEOS) 81 #if defined(OS_CHROMEOS)
82 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
82 #include "chrome/browser/chromeos/login/users/user.h" 83 #include "chrome/browser/chromeos/login/users/user.h"
83 #include "chrome/browser/chromeos/net/onc_utils.h" 84 #include "chrome/browser/chromeos/net/onc_utils.h"
84 #include "chrome/browser/chromeos/profiles/profile_helper.h" 85 #include "chrome/browser/chromeos/profiles/profile_helper.h"
85 #include "chrome/browser/chromeos/system/syslogs_provider.h" 86 #include "chrome/browser/chromeos/system/syslogs_provider.h"
86 #include "chrome/browser/net/nss_context.h" 87 #include "chrome/browser/net/nss_context.h"
87 #include "chromeos/dbus/dbus_thread_manager.h" 88 #include "chromeos/dbus/dbus_thread_manager.h"
88 #include "chromeos/dbus/debug_daemon_client.h" 89 #include "chromeos/dbus/debug_daemon_client.h"
89 #include "chromeos/network/onc/onc_certificate_importer_impl.h" 90 #include "chromeos/network/onc/onc_certificate_importer_impl.h"
90 #include "chromeos/network/onc/onc_utils.h" 91 #include "chromeos/network/onc/onc_utils.h"
91 #endif 92 #endif
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // Stores into |file_path| debug logs in the .tgz format. Calls 239 // Stores into |file_path| debug logs in the .tgz format. Calls
239 // |callback| upon completion. 240 // |callback| upon completion.
240 void WriteDebugLogToFile(const StoreDebugLogsCallback& callback, 241 void WriteDebugLogToFile(const StoreDebugLogsCallback& callback,
241 base::File* file, 242 base::File* file,
242 const base::FilePath& file_path) { 243 const base::FilePath& file_path) {
243 DCHECK_CURRENTLY_ON(BrowserThread::UI); 244 DCHECK_CURRENTLY_ON(BrowserThread::UI);
244 if (!file->IsValid()) { 245 if (!file->IsValid()) {
245 LOG(ERROR) << 246 LOG(ERROR) <<
246 "Can't create debug log file: " << file_path.AsUTF8Unsafe() << ", " << 247 "Can't create debug log file: " << file_path.AsUTF8Unsafe() << ", " <<
247 "error: " << file->error_details(); 248 "error: " << file->error_details();
249 callback.Run(file_path, false);
248 return; 250 return;
249 } 251 }
250 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->GetDebugLogs( 252 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->GetDebugLogs(
251 file->Pass(), 253 file->Pass(),
252 base::Bind(&WriteDebugLogToFileCompleted, callback, file_path)); 254 base::Bind(&WriteDebugLogToFileCompleted, callback, file_path));
253 } 255 }
254 256
255 // Stores debug logs in the .tgz archive on the |fileshelf|. The file 257 // Stores debug logs in the .tgz archive on the |fileshelf|. The file
256 // is created on the worker pool, then writing to it is triggered from 258 // is created on the worker pool, then writing to it is triggered from
257 // the UI thread, and finally it is closed (on success) or deleted (on 259 // the UI thread, and finally it is closed (on success) or deleted (on
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 Profile::FromWebUI(web_ui()), 1527 Profile::FromWebUI(web_ui()),
1526 base::Bind(&NetInternalsMessageHandler::ImportONCFileToNSSDB, AsWeakPtr(), 1528 base::Bind(&NetInternalsMessageHandler::ImportONCFileToNSSDB, AsWeakPtr(),
1527 onc_blob, passcode)); 1529 onc_blob, passcode));
1528 } 1530 }
1529 1531
1530 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { 1532 void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) {
1531 DCHECK(list); 1533 DCHECK(list);
1532 1534
1533 SendJavascriptCommand("receivedStoreDebugLogs", 1535 SendJavascriptCommand("receivedStoreDebugLogs",
1534 new base::StringValue("Creating log file...")); 1536 new base::StringValue("Creating log file..."));
1535 const DownloadPrefs* const prefs = 1537 Profile* const profile = Profile::FromWebUI(web_ui());
1536 DownloadPrefs::FromBrowserContext(Profile::FromWebUI(web_ui())); 1538 const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile);
1537 StoreDebugLogs(prefs->DownloadPath(), 1539 base::FilePath path = prefs->DownloadPath();
1540 if (file_manager::util::IsUnderNonNativeLocalPath(profile, path))
1541 path = prefs->GetDefaultDownloadDirectoryForProfile();
1542 StoreDebugLogs(path,
1538 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, 1543 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted,
1539 AsWeakPtr())); 1544 AsWeakPtr()));
1540 } 1545 }
1541 1546
1542 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( 1547 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted(
1543 const base::FilePath& log_path, bool succeeded) { 1548 const base::FilePath& log_path, bool succeeded) {
1544 std::string status; 1549 std::string status;
1545 if (succeeded) 1550 if (succeeded)
1546 status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); 1551 status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe();
1547 else 1552 else
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 } 1778 }
1774 1779
1775 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) 1780 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui)
1776 : WebUIController(web_ui) { 1781 : WebUIController(web_ui) {
1777 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); 1782 web_ui->AddMessageHandler(new NetInternalsMessageHandler());
1778 1783
1779 // Set up the chrome://net-internals/ source. 1784 // Set up the chrome://net-internals/ source.
1780 Profile* profile = Profile::FromWebUI(web_ui); 1785 Profile* profile = Profile::FromWebUI(web_ui);
1781 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); 1786 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource());
1782 } 1787 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698