/core/externals/update-engine/Core/KSUpdateCheckAction.h

http://macfuse.googlecode.com/ · C Header · 91 lines · 27 code · 14 blank · 50 comment · 0 complexity · 0e9556d9f5b9c6faf7581cf08e63e5fd 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 <Foundation/Foundation.h>
  15. #import "KSAction.h"
  16. @class KSFetcherFactory;
  17. @class KSServer;
  18. @class GDataHTTPFetcher;
  19. @class KSFetcherFactory;
  20. // The KSUpdateCheckAction class checks for updates. Its input consists of:
  21. // - a KSServer which encapsulates the server communication;
  22. // - an array of tickets, represting local installs which may need
  23. // updating; and
  24. // - an optional fetcher factory which encapsulates a
  25. // request/response (e.g. loading of a URL request).
  26. // All tickets must point to the same server URL.
  27. //
  28. // If there are updates to perform, the KSUpdateCheckAction will take
  29. // the KSActions generated by its KSServer, presumably
  30. // KSUpdateActions, and place them on it's own action processor. This
  31. // class will finish (call the KSActionProcessor's
  32. // finishedProcessing:successfully:) when done deciding what to do,
  33. // which may be before its "child" KSUpdateActions have completed.
  34. //
  35. // This class is the only interface that KSUpdateEngine will use for
  36. // server communication. It is expected that KSUpdateEngine will create a
  37. // KSUpdateCheckAction for each unique server URL seen in a ticket
  38. // store.
  39. @interface KSUpdateCheckAction : KSAction {
  40. @private
  41. KSFetcherFactory *fetcherFactory_;
  42. KSServer *server_;
  43. NSArray *tickets_;
  44. // Array of fetchers we have created. Size of this array is the
  45. // number of outstanding requests.
  46. NSMutableArray *fetchers_;
  47. // If any request is unsucessful, this is set to NO.
  48. BOOL allSuccessful_;
  49. id delegate_; // weak
  50. }
  51. + (id)checkerWithServer:(KSServer *)server tickets:(NSArray *)tickets;
  52. // Calls through to designated initializer with a new instance of
  53. // GDataHTTPFetcher. This is the standard initailizer that you will
  54. // almost always want to use. |tickets|, an array of KSTickets, are
  55. // required to all point to the same server URL.
  56. - (id)initWithServer:(KSServer *)server tickets:(NSArray *)tickets;
  57. // Designated initializer. Can be useful because a mock fetcher can be
  58. // "injected" into the instance when testing.
  59. - (id)initWithFetcherFactory:(KSFetcherFactory *)fetcherFactory
  60. server:(KSServer *)server
  61. tickets:(NSArray *)tickets;
  62. // Return the number of outstanding requests. Servers may have
  63. // more than one outstanding request each.
  64. - (int)outstandingRequests;
  65. // Getter and setter for this object's optional delegate. See
  66. // KSUpdateCheckActionDelegateMethods below for details about the callbacks
  67. // that the delegate can receive.
  68. - (id)delegate;
  69. - (void)setDelegate:(id)delegate;
  70. @end
  71. // Protocol for a delegate which receives error messages. Currently
  72. // fetcher errors are logged and thrown away. (An error here has the
  73. // functional meaning "do nothing more".) Use of a delegate with this
  74. // protocol in KSUpdateCheckAction is optional.
  75. @interface KSUpdateCheckAction (KSUpdateCheckActionDelegateMethods)
  76. - (void)fetcher:(GDataHTTPFetcher *)fetcher failedWithError:(NSError *)error;
  77. @end