OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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. | |
4 | |
5 #ifndef CHROME_BROWSER_INTENTS_INTENTS_REGISTRY_H_ | |
6 #define CHROME_BROWSER_INTENTS_INTENTS_REGISTRY_H_ | |
7 #pragma once | |
8 | |
9 #include "base/hash_tables.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "chrome/browser/intents/web_intent_data.h" | |
12 #include "chrome/browser/webdata/web_data_service.h" | |
13 | |
14 // Handles storing & retrieving of web intents in the web database. | |
James Hawkins
2011/08/04 17:34:51
s/&/and/
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
15 // It provides filtering logic to retrieve specific types of intents. | |
James Hawkins
2011/08/04 17:34:51
Use a more descriptive word than 'It'.
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
16 class IntentsRegistry: public WebDataServiceConsumer { | |
James Hawkins
2011/08/04 17:34:51
WebIntentsRegistry
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
17 public: | |
18 typedef int QueryID; // unique identifier for intent queries. | |
19 | |
20 // An interface the IntentsRegistry uses to notify its clients when | |
21 // it has finished loading intents data from the web database. | |
22 class Consumer { | |
James Hawkins
2011/08/04 17:34:51
Specify this interface in a separate file (for iwy
groby-ooo-7-16
2011/08/05 20:40:09
Skipped, since it's closely tied to the registry.
| |
23 public: | |
24 // Notifies the observer that the intents request has been completed. | |
25 virtual void OnIntentsQueryDone( | |
26 QueryID query_id, | |
27 const std::vector<WebIntentData>& intents) = 0; | |
28 | |
29 protected: | |
30 virtual ~Consumer() {} | |
31 }; | |
32 | |
33 IntentsRegistry(); | |
34 virtual ~IntentsRegistry(); | |
35 | |
36 // Initialize registry and bind to a valid WebDataService. | |
James Hawkins
2011/08/04 17:34:51
Initializes, binds
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
37 void Initialize(scoped_refptr<WebDataService> wds); | |
38 | |
39 // Registers a web intent provider. | |
40 void RegisterIntentProvider(const WebIntentData& intent); | |
41 | |
42 // Removes a web intent provider from the registry. | |
43 void UnregisterIntentProvider(const WebIntentData& intent); | |
44 | |
45 // Request all intent providers matching |action|. | |
James Hawkins
2011/08/04 17:34:51
s/Request/Returns/
groby-ooo-7-16
2011/08/05 20:40:09
This is an async call (see use of consumer) - henc
| |
46 // |consumer| must not be NULL. | |
47 QueryID GetIntentProviders(const string16& action, Consumer* consumer); | |
48 | |
49 private: | |
50 // WebDataServiceConsumer implementation: | |
James Hawkins
2011/08/04 17:34:51
s/:/./
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
51 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, | |
52 const WDTypedResult* result); | |
53 | |
54 // Internal object representing a single intents query. | |
55 struct IntentsQuery { | |
James Hawkins
2011/08/04 17:34:51
Perhaps we should forward declare the struct?
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
56 // WebDataService returns data asynchronously from a separate thread, so | |
57 // registry records the query handle until we get called back. | |
58 QueryID query_id_; // unique query identifier. | |
59 WebDataService::Handle pending_query_; // Underlying data query. | |
60 Consumer* consumer_; // the consumer for this particular query. | |
61 | |
62 // TODO(groby): Additional filter data will go here - filtering is handled | |
63 // per query. | |
64 }; | |
65 | |
66 typedef base::hash_map<WebDataService::Handle, IntentsQuery*> QueryMap; | |
James Hawkins
2011/08/04 17:34:51
typedefs go at the top of the private section.
James Hawkins
2011/08/04 17:34:51
Document this typedef.
groby-ooo-7-16
2011/08/05 20:40:09
Done.
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
67 | |
68 QueryMap queries; | |
James Hawkins
2011/08/04 17:34:51
Document all vars.
groby-ooo-7-16
2011/08/05 20:40:09
Done.
| |
69 QueryID next_query_id_; | |
70 scoped_refptr<WebDataService> wds_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(IntentsRegistry); | |
73 }; | |
74 | |
75 #endif // CHROME_BROWSER_INTENTS_INTENTS_REGISTRY_H_ | |
OLD | NEW |