hunspell: Cleanup to fix the header include guards under google/ directory.
[chromium-blink-merge.git] / ios / web / crw_network_activity_indicator_manager.h
blob5af8f147286cb4feaf5f28097dd88492d3b0b9e1
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
3 // found in the LICENSE file.
5 #ifndef IOS_WEB_CRW_NETWORK_ACTIVITY_INDICATOR_MANAGER_H_
6 #define IOS_WEB_CRW_NETWORK_ACTIVITY_INDICATOR_MANAGER_H_
8 #import <Foundation/Foundation.h>
10 // This class controls access to the network activity indicator across the
11 // app. It provides a simple interface for clients to indicate they are
12 // starting a network task and they would like the indicator shown, and to
13 // indicate they have finished a network task.
15 // Clients are required to pass an NSString* to each method to identify
16 // themselves. Separating clients into groups prevents a client from "stopping"
17 // requests from other clients on accident, and makes those bugs easier to
18 // track down. Specifically, the manager will immediately fail if the number
19 // of tasks stopped for a group ever exceeds the number of tasks started for
20 // that group. Clients are responsible for namespacing their group strings
21 // properly. All methods must be called on the UI thread.
22 @interface CRWNetworkActivityIndicatorManager : NSObject
24 // Returns the singleton CRWNetworkActivityIndicatorManager.
25 + (CRWNetworkActivityIndicatorManager*)sharedInstance;
27 // Begins a single network task. The network activity indicator is guaranteed
28 // to be shown after this finishes (if it isn't already). |group| must be
29 // non-nil.
30 - (void)startNetworkTaskForGroup:(NSString*)group;
32 // Stops a single network task. The network activity indicator may or may not
33 // stop being shown once this finishes, depending on whether there are other
34 // unstopped tasks or not. |group| must be non-nil, and have at least one
35 // unstopped task.
36 - (void)stopNetworkTaskForGroup:(NSString*)group;
38 // A convenience method for starting multiple network tasks at once. |group|
39 // must be non-nil. |numTasks| must be greater than 0.
40 - (void)startNetworkTasks:(NSUInteger)numTasks forGroup:(NSString*)group;
42 // A convenience method for stopping multiple network tasks at once. |group|
43 // must be non-nil. |numTasks| must be greater than 0, and |numTasks| must be
44 // less than or equal to the number of unstopped tasks in |group|.
45 - (void)stopNetworkTasks:(NSUInteger)numTasks forGroup:(NSString*)group;
47 // A convenience method for stopping all network tasks for a group. |group|
48 // must be non-nil. Can be called on any group at any time, regardless of
49 // whether the group has any unstopped network tasks or not. Returns the number
50 // of tasks stopped by this call.
51 - (NSUInteger)clearNetworkTasksForGroup:(NSString*)group;
53 // Returns the number of unstopped network tasks for |group|. |group| must be
54 // non-nil. Can be called on any group at any time, regardless of whether the
55 // group has any unstopped network tasks or not.
56 - (NSUInteger)numNetworkTasksForGroup:(NSString*)group;
58 // Returns the total number of unstopped network tasks, across all groups. This
59 // method was added for testing only. Clients should never depend on this, and
60 // should instead only be concerned with the number of unstopped network tasks
61 // for the groups they control, which can be queried using
62 // |-numNetworkTasksForGroup:|.
63 - (NSUInteger)numTotalNetworkTasks;
65 @end
67 #endif // IOS_WEB_CRW_NETWORK_ACTIVITY_INDICATOR_MANAGER_H_