PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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