Chromium Code Reviews| Index: chrome/browser/intents/intents_registry.h |
| diff --git a/chrome/browser/intents/intents_registry.h b/chrome/browser/intents/intents_registry.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..626426aaae2dcf778eeaf4874203fce0d429fb8f |
| --- /dev/null |
| +++ b/chrome/browser/intents/intents_registry.h |
| @@ -0,0 +1,75 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_INTENTS_INTENTS_REGISTRY_H_ |
| +#define CHROME_BROWSER_INTENTS_INTENTS_REGISTRY_H_ |
| +#pragma once |
| + |
| +#include "base/hash_tables.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/browser/intents/web_intent_data.h" |
| +#include "chrome/browser/webdata/web_data_service.h" |
| + |
| +// 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.
|
| +// 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.
|
| +class IntentsRegistry: public WebDataServiceConsumer { |
|
James Hawkins
2011/08/04 17:34:51
WebIntentsRegistry
groby-ooo-7-16
2011/08/05 20:40:09
Done.
|
| + public: |
| + typedef int QueryID; // unique identifier for intent queries. |
| + |
| + // An interface the IntentsRegistry uses to notify its clients when |
| + // it has finished loading intents data from the web database. |
| + 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.
|
| + public: |
| + // Notifies the observer that the intents request has been completed. |
| + virtual void OnIntentsQueryDone( |
| + QueryID query_id, |
| + const std::vector<WebIntentData>& intents) = 0; |
| + |
| + protected: |
| + virtual ~Consumer() {} |
| + }; |
| + |
| + IntentsRegistry(); |
| + virtual ~IntentsRegistry(); |
| + |
| + // 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.
|
| + void Initialize(scoped_refptr<WebDataService> wds); |
| + |
| + // Registers a web intent provider. |
| + void RegisterIntentProvider(const WebIntentData& intent); |
| + |
| + // Removes a web intent provider from the registry. |
| + void UnregisterIntentProvider(const WebIntentData& intent); |
| + |
| + // 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
|
| + // |consumer| must not be NULL. |
| + QueryID GetIntentProviders(const string16& action, Consumer* consumer); |
| + |
| + private: |
| + // WebDataServiceConsumer implementation: |
|
James Hawkins
2011/08/04 17:34:51
s/:/./
groby-ooo-7-16
2011/08/05 20:40:09
Done.
|
| + virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, |
| + const WDTypedResult* result); |
| + |
| + // Internal object representing a single intents query. |
| + 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.
|
| + // WebDataService returns data asynchronously from a separate thread, so |
| + // registry records the query handle until we get called back. |
| + QueryID query_id_; // unique query identifier. |
| + WebDataService::Handle pending_query_; // Underlying data query. |
| + Consumer* consumer_; // the consumer for this particular query. |
| + |
| + // TODO(groby): Additional filter data will go here - filtering is handled |
| + // per query. |
| + }; |
| + |
| + 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.
|
| + |
| + QueryMap queries; |
|
James Hawkins
2011/08/04 17:34:51
Document all vars.
groby-ooo-7-16
2011/08/05 20:40:09
Done.
|
| + QueryID next_query_id_; |
| + scoped_refptr<WebDataService> wds_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(IntentsRegistry); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_INTENTS_INTENTS_REGISTRY_H_ |