OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/chrome/app/main_controller.h" | 5 #import "ios/chrome/app/main_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #import <CoreSpotlight/CoreSpotlight.h> | 10 #import <CoreSpotlight/CoreSpotlight.h> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 NSString* const kAuthenticationServiceNotification = | 160 NSString* const kAuthenticationServiceNotification = |
161 @"AuthenticationServiceNotification"; | 161 @"AuthenticationServiceNotification"; |
162 | 162 |
163 // Constants for deferring reseting the startup attempt count (to give the app | 163 // Constants for deferring reseting the startup attempt count (to give the app |
164 // a little while to make sure it says alive). | 164 // a little while to make sure it says alive). |
165 NSString* const kStartupAttemptReset = @"StartupAttempReset"; | 165 NSString* const kStartupAttemptReset = @"StartupAttempReset"; |
166 | 166 |
167 // Constants for deferring memory debugging tools startup. | 167 // Constants for deferring memory debugging tools startup. |
168 NSString* const kMemoryDebuggingToolsStartup = @"MemoryDebuggingToolsStartup"; | 168 NSString* const kMemoryDebuggingToolsStartup = @"MemoryDebuggingToolsStartup"; |
169 | 169 |
170 // Constants for deferring memory monitoring startup. | |
171 NSString* const kMemoryMonitoring = @"MemoryMonitoring"; | |
172 | |
173 // Constants for deferred check if it is necessary to send pings to | 170 // Constants for deferred check if it is necessary to send pings to |
174 // Chrome distribution related services. | 171 // Chrome distribution related services. |
175 NSString* const kSendInstallPingIfNecessary = @"SendInstallPingIfNecessary"; | 172 NSString* const kSendInstallPingIfNecessary = @"SendInstallPingIfNecessary"; |
176 | 173 |
177 // Constants for deferring check of native iOS apps installed. | 174 // Constants for deferring check of native iOS apps installed. |
178 NSString* const kCheckNativeApps = @"CheckNativeApps"; | 175 NSString* const kCheckNativeApps = @"CheckNativeApps"; |
179 | 176 |
180 // Constants for deferred deletion of leftover user downloaded files. | 177 // Constants for deferred deletion of leftover user downloaded files. |
181 NSString* const kDeleteDownloads = @"DeleteDownloads"; | 178 NSString* const kDeleteDownloads = @"DeleteDownloads"; |
182 | 179 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // Asynchronously creates the pref observers. | 469 // Asynchronously creates the pref observers. |
473 - (void)schedulePrefObserverInitialization; | 470 - (void)schedulePrefObserverInitialization; |
474 // Asynchronously schedules a check for what other native iOS apps are currently | 471 // Asynchronously schedules a check for what other native iOS apps are currently |
475 // installed. | 472 // installed. |
476 - (void)scheduleCheckNativeApps; | 473 - (void)scheduleCheckNativeApps; |
477 // Asynchronously schedules pings to distribution services. | 474 // Asynchronously schedules pings to distribution services. |
478 - (void)scheduleAppDistributionPings; | 475 - (void)scheduleAppDistributionPings; |
479 // Asynchronously schedule the init of the memoryDebuggerManager. | 476 // Asynchronously schedule the init of the memoryDebuggerManager. |
480 - (void)scheduleMemoryDebuggingTools; | 477 - (void)scheduleMemoryDebuggingTools; |
481 // Asynchronously kick off regular free memory checks. | 478 // Asynchronously kick off regular free memory checks. |
482 - (void)scheduleFreeMemoryMonitoring; | 479 - (void)startFreeMemoryMonitoring; |
483 // Asynchronously schedules the notification of the AuthenticationService. | 480 // Asynchronously schedules the notification of the AuthenticationService. |
484 - (void)scheduleAuthenticationServiceNotification; | 481 - (void)scheduleAuthenticationServiceNotification; |
485 // Asynchronously schedules the reset of the failed startup attempt counter. | 482 // Asynchronously schedules the reset of the failed startup attempt counter. |
486 - (void)scheduleStartupAttemptReset; | 483 - (void)scheduleStartupAttemptReset; |
487 // Asynchronously schedules the cleanup of crash reports. | 484 // Asynchronously schedules the cleanup of crash reports. |
488 - (void)scheduleCrashReportCleanup; | 485 - (void)scheduleCrashReportCleanup; |
489 // Asynchronously schedules the deletion of old snapshots. | 486 // Asynchronously schedules the deletion of old snapshots. |
490 - (void)scheduleSnapshotPurge; | 487 - (void)scheduleSnapshotPurge; |
491 // Schedules various cleanup tasks that are performed after launch. | 488 // Schedules various cleanup tasks that are performed after launch. |
492 - (void)scheduleStartupCleanupTasks; | 489 - (void)scheduleStartupCleanupTasks; |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 block:^{ | 1156 block:^{ |
1160 _memoryDebuggerManager.reset( | 1157 _memoryDebuggerManager.reset( |
1161 [[MemoryDebuggerManager alloc] | 1158 [[MemoryDebuggerManager alloc] |
1162 initWithView:self.window | 1159 initWithView:self.window |
1163 prefs:GetApplicationContext() | 1160 prefs:GetApplicationContext() |
1164 ->GetLocalState()]); | 1161 ->GetLocalState()]); |
1165 }]; | 1162 }]; |
1166 } | 1163 } |
1167 } | 1164 } |
1168 | 1165 |
1169 - (void)scheduleFreeMemoryMonitoring { | 1166 - (void)startFreeMemoryMonitoring { |
1170 // TODO(crbug.com/649338): See if this method cannot call PostBlockingPoolTask | 1167 web::WebThread::PostBlockingPoolTask( |
1171 // directly instead of enqueueing a block. | 1168 FROM_HERE, base::Bind(&ios_internal::AsynchronousFreeMemoryMonitor)); |
1172 [[DeferredInitializationRunner sharedInstance] | |
1173 enqueueBlockNamed:kMemoryMonitoring | |
1174 block:^{ | |
1175 web::WebThread::PostBlockingPoolTask( | |
1176 FROM_HERE, | |
1177 base::Bind( | |
1178 &ios_internal::AsynchronousFreeMemoryMonitor)); | |
1179 }]; | |
1180 } | 1169 } |
1181 | 1170 |
1182 - (void)scheduleLowPriorityStartupTasks { | 1171 - (void)scheduleLowPriorityStartupTasks { |
1183 [_startupTasks initializeOmaha]; | 1172 [_startupTasks initializeOmaha]; |
1184 [_startupTasks registerForApplicationWillResignActiveNotification]; | 1173 [_startupTasks registerForApplicationWillResignActiveNotification]; |
1185 [self registerForOrientationChangeNotifications]; | 1174 [self registerForOrientationChangeNotifications]; |
1186 | 1175 |
1187 // Deferred tasks. | 1176 // Deferred tasks. |
1188 [self schedulePrefObserverInitialization]; | 1177 [self schedulePrefObserverInitialization]; |
1189 [self scheduleMemoryDebuggingTools]; | 1178 [self scheduleMemoryDebuggingTools]; |
1190 [_startupTasks scheduleDeferredBrowserStateInitialization:_mainBrowserState]; | 1179 [_startupTasks scheduleDeferredBrowserStateInitialization:_mainBrowserState]; |
1191 [self scheduleAuthenticationServiceNotification]; | 1180 [self scheduleAuthenticationServiceNotification]; |
1192 [self sendQueuedFeedback]; | 1181 [self sendQueuedFeedback]; |
1193 [self scheduleSpotlightResync]; | 1182 [self scheduleSpotlightResync]; |
1194 [self scheduleDeleteDownloadsDirectory]; | 1183 [self scheduleDeleteDownloadsDirectory]; |
1195 [self scheduleStartupAttemptReset]; | 1184 [self scheduleStartupAttemptReset]; |
1196 [self scheduleFreeMemoryMonitoring]; | 1185 [self startFreeMemoryMonitoring]; |
1197 [self scheduleAppDistributionPings]; | 1186 [self scheduleAppDistributionPings]; |
1198 [self scheduleCheckNativeApps]; | 1187 [self scheduleCheckNativeApps]; |
1199 } | 1188 } |
1200 | 1189 |
1201 - (void)scheduleTasksRequiringBVCWithBrowserState { | 1190 - (void)scheduleTasksRequiringBVCWithBrowserState { |
1202 if (GetApplicationContext()->WasLastShutdownClean()) | 1191 if (GetApplicationContext()->WasLastShutdownClean()) |
1203 [self.mainBVC removeExternalFilesImmediately:NO completionHandler:nil]; | 1192 [self.mainBVC removeExternalFilesImmediately:NO completionHandler:nil]; |
1204 | 1193 |
1205 [self scheduleShowPromo]; | 1194 [self scheduleShowPromo]; |
1206 } | 1195 } |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2611 }; | 2600 }; |
2612 | 2601 |
2613 callbackCounter->IncrementCount(); | 2602 callbackCounter->IncrementCount(); |
2614 [self removeBrowsingDataFromBrowserState:_mainBrowserState | 2603 [self removeBrowsingDataFromBrowserState:_mainBrowserState |
2615 mask:removeAllMask | 2604 mask:removeAllMask |
2616 timePeriod:browsing_data::TimePeriod::ALL_TIME | 2605 timePeriod:browsing_data::TimePeriod::ALL_TIME |
2617 completionHandler:decrementCallbackCounterCount]; | 2606 completionHandler:decrementCallbackCounterCount]; |
2618 } | 2607 } |
2619 | 2608 |
2620 @end | 2609 @end |
OLD | NEW |