1 // Copyright 2013 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 CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_CACHE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_CACHE_H_
10 #include "base/basictypes.h"
11 #include "base/containers/mru_cache.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h"
16 class DictionaryValue
;
21 // WebstoreCache manages the cache of webstore search results which should
22 // be valid during an input session. This will reduce unnecessary queries
23 // for typing backspace or so on.
29 // Checks the current cache and returns the value for the |query| if it's
30 // valid. Otherwise returns NULL.
31 const base::DictionaryValue
* Get(const std::string
& query
);
33 // Puts the new result to the query.
34 void Put(const std::string
& query
, scoped_ptr
<base::DictionaryValue
> result
);
37 typedef std::pair
<base::Time
, base::DictionaryValue
*> Payload
;
40 void operator()(Payload
& payload
);
42 typedef base::MRUCacheBase
<std::string
, Payload
, CacheDeletor
> Cache
;
46 DISALLOW_COPY_AND_ASSIGN(WebstoreCache
);
49 } // namespace app_list
51 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_CACHE_H_