OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_ | 5 #ifndef CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_ |
6 #define CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_ | 6 #define CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "chrome/browser/profiles/profile_keyed_service.h" | 13 #include "chrome/browser/profiles/profile_keyed_service.h" |
14 #include "content/public/common/url_fetcher_delegate.h" | |
15 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "net/url_request/url_fetcher_delegate.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class URLRequestContextGetter; | 18 class URLRequestContextGetter; |
19 } | 19 } |
20 | 20 |
21 // Handles storing and retrieving of web intents in the web database. | 21 // Handles storing and retrieving of web intents in the web database. |
22 // The registry provides filtering logic to retrieve specific types of intents. | 22 // The registry provides filtering logic to retrieve specific types of intents. |
23 class CWSIntentsRegistry : public ProfileKeyedService, | 23 class CWSIntentsRegistry : public ProfileKeyedService, |
24 public content::URLFetcherDelegate { | 24 public net::URLFetcherDelegate { |
25 public: | 25 public: |
26 // Data returned from CWS for a single service. | 26 // Data returned from CWS for a single service. |
27 struct IntentExtensionInfo { | 27 struct IntentExtensionInfo { |
28 IntentExtensionInfo(); | 28 IntentExtensionInfo(); |
29 ~IntentExtensionInfo(); | 29 ~IntentExtensionInfo(); |
30 | 30 |
31 string16 id; // The id of the extension. | 31 string16 id; // The id of the extension. |
32 string16 name; // The name of the extension. | 32 string16 name; // The name of the extension. |
33 int num_ratings; // Number of ratings in CWS store. | 33 int num_ratings; // Number of ratings in CWS store. |
34 double average_rating; // The average CWS rating. | 34 double average_rating; // The average CWS rating. |
(...skipping 30 matching lines...) Expand all Loading... |
65 // This is an opaque version of URLFetcher*, so we can use it as a hash key. | 65 // This is an opaque version of URLFetcher*, so we can use it as a hash key. |
66 typedef intptr_t URLFetcherHandle; | 66 typedef intptr_t URLFetcherHandle; |
67 | 67 |
68 // Maps URL fetchers to queries. IntentsQuery objects are owned by the map. | 68 // Maps URL fetchers to queries. IntentsQuery objects are owned by the map. |
69 typedef base::hash_map<URLFetcherHandle, IntentsQuery*> QueryMap; | 69 typedef base::hash_map<URLFetcherHandle, IntentsQuery*> QueryMap; |
70 | 70 |
71 // |context| is a profile-dependent URL request context. Must not be NULL. | 71 // |context| is a profile-dependent URL request context. Must not be NULL. |
72 explicit CWSIntentsRegistry(net::URLRequestContextGetter* context); | 72 explicit CWSIntentsRegistry(net::URLRequestContextGetter* context); |
73 virtual ~CWSIntentsRegistry(); | 73 virtual ~CWSIntentsRegistry(); |
74 | 74 |
75 // content::URLFetcherDelegate implementation. | 75 // net::URLFetcherDelegate implementation. |
76 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 76 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
77 | 77 |
78 // Map for all in-flight web data requests/intent queries. | 78 // Map for all in-flight web data requests/intent queries. |
79 QueryMap queries_; | 79 QueryMap queries_; |
80 | 80 |
81 // Request context for any CWS requests. | 81 // Request context for any CWS requests. |
82 scoped_refptr<net::URLRequestContextGetter> request_context_; | 82 scoped_refptr<net::URLRequestContextGetter> request_context_; |
83 | 83 |
84 DISALLOW_COPY_AND_ASSIGN(CWSIntentsRegistry); | 84 DISALLOW_COPY_AND_ASSIGN(CWSIntentsRegistry); |
85 }; | 85 }; |
86 | 86 |
87 #endif // CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_ | 87 #endif // CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_ |
OLD | NEW |