/core/externals/update-engine/Core/KSPromptAction.m

http://macfuse.googlecode.com/ · Objective C · 50 lines · 22 code · 8 blank · 20 comment · 1 complexity · 6b62902284636342982cfe5c8fe306eb MD5 · raw file

  1. // Copyright 2008 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "KSPromptAction.h"
  15. #import "KSUpdateEngine.h"
  16. #import "KSActionProcessor.h"
  17. #import "KSActionPipe.h"
  18. #import "KSUpdateInfo.h"
  19. #import "KSUpdateAction.h"
  20. #import "KSFrameworkStats.h"
  21. @implementation KSPromptAction
  22. // A quick note about stats:
  23. //
  24. // We collect 3 stats in this method.
  25. // kStatPrompts - which is the number of times we send a list of avail updates
  26. // kStatPromptApps - which is the number of apps that we prompted about
  27. // kStatPromptUpdates - which is the number of apps that the user was prompted
  28. // for, and the user said "yes" to installing the update
  29. - (NSArray *)productsToUpdateFromAvailable:(NSArray *)availableUpdates {
  30. int numUpdates = [availableUpdates count];
  31. if (numUpdates > 0) {
  32. [[KSFrameworkStats sharedStats] incrementStat:kStatPrompts];
  33. [[KSFrameworkStats sharedStats] incrementStat:kStatPromptApps
  34. by:numUpdates];
  35. }
  36. NSArray *updatesToInstall = [[self engine] action:self
  37. shouldUpdateProducts:availableUpdates];
  38. [[KSFrameworkStats sharedStats] incrementStat:kStatPromptUpdates
  39. by:[updatesToInstall count]];
  40. return updatesToInstall;
  41. }
  42. @end