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

Side by Side Diff: chrome/browser/media/webrtc_log_util.cc

Issue 299903002: Convert WebRtcLoggingHandlerHost to use the blocking thread pool. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix after r273980 Created 6 years, 6 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
OLDNEW
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 "chrome/browser/media/webrtc_log_util.h" 5 #include "chrome/browser/media/webrtc_log_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/file_path.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/threading/thread_restrictions.h"
10 #include "base/time/time.h" 12 #include "base/time/time.h"
11 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/media/webrtc_log_list.h" 14 #include "chrome/browser/media/webrtc_log_list.h"
13 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
15 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
16 18
17 namespace { 19 namespace {
18 20
19 const int kDaysToKeepLogs = 5; 21 const int kDaysToKeepLogs = 5;
(...skipping 17 matching lines...) Expand all
37 39
38 // static 40 // static
39 void WebRtcLogUtil::DeleteOldWebRtcLogFiles(const base::FilePath& log_dir) { 41 void WebRtcLogUtil::DeleteOldWebRtcLogFiles(const base::FilePath& log_dir) {
40 DeleteOldAndRecentWebRtcLogFiles(log_dir, base::Time::Max()); 42 DeleteOldAndRecentWebRtcLogFiles(log_dir, base::Time::Max());
41 } 43 }
42 44
43 // static 45 // static
44 void WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles( 46 void WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles(
45 const base::FilePath& log_dir, 47 const base::FilePath& log_dir,
46 const base::Time& delete_begin_time) { 48 const base::Time& delete_begin_time) {
47 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 49 base::ThreadRestrictions::AssertIOAllowed();
48 50
49 if (!base::PathExists(log_dir)) { 51 if (!base::PathExists(log_dir)) {
50 // This will happen if no logs have been stored or uploaded. 52 // This will happen if no logs have been stored or uploaded.
51 DVLOG(3) << "Could not find directory: " << log_dir.value(); 53 DVLOG(3) << "Could not find directory: " << log_dir.value();
52 return; 54 return;
53 } 55 }
54 56
55 const base::Time now = base::Time::Now(); 57 const base::Time now = base::Time::Now();
56 const base::TimeDelta time_to_keep_logs = 58 const base::TimeDelta time_to_keep_logs =
57 base::TimeDelta::FromDays(kDaysToKeepLogs); 59 base::TimeDelta::FromDays(kDaysToKeepLogs);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 103 }
102 104
103 // static 105 // static
104 void WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles() { 106 void WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles() {
105 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 107 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
106 108
107 ProfileInfoCache& profile_cache = 109 ProfileInfoCache& profile_cache =
108 g_browser_process->profile_manager()->GetProfileInfoCache(); 110 g_browser_process->profile_manager()->GetProfileInfoCache();
109 size_t profiles_count = profile_cache.GetNumberOfProfiles(); 111 size_t profiles_count = profile_cache.GetNumberOfProfiles();
110 for (size_t i = 0; i < profiles_count; ++i) { 112 for (size_t i = 0; i < profiles_count; ++i) {
111 content::BrowserThread::PostTask( 113 content::BrowserThread::PostBlockingPoolTask(
112 content::BrowserThread::FILE,
113 FROM_HERE, 114 FROM_HERE,
114 base::Bind(&DeleteOldWebRtcLogFiles, 115 base::Bind(&DeleteOldWebRtcLogFiles,
115 WebRtcLogList::GetWebRtcLogDirectoryForProfile( 116 WebRtcLogList::GetWebRtcLogDirectoryForProfile(
116 profile_cache.GetPathOfProfileAtIndex(i)))); 117 profile_cache.GetPathOfProfileAtIndex(i))));
117 } 118 }
118 } 119 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_log_util.h ('k') | chrome/browser/media/webrtc_logging_handler_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698