Revert of Enabling audio quality test on mac. (patchset #1 id:1 of https://codereview...
[chromium-blink-merge.git] / components / enhanced_bookmarks / bookmark_server_search_service.h
blob847c85f34a1c7008ccbe2d46a4c5a8875be14b1f
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 COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_
6 #define COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_
8 #include <string>
9 #include <vector>
11 #include "components/bookmarks/browser/base_bookmark_model_observer.h"
12 #include "components/enhanced_bookmarks/bookmark_server_service.h"
13 #include "net/url_request/url_fetcher.h"
15 namespace enhanced_bookmarks {
17 class EnhancedBookmarkModel;
19 // Sends requests to the bookmark server to search for bookmarks relevant to a
20 // given query. Will handle one outgoing request at a time.
21 class BookmarkServerSearchService : public BookmarkServerService {
22 public:
23 BookmarkServerSearchService(
24 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
25 ProfileOAuth2TokenService* token_service,
26 SigninManagerBase* signin_manager,
27 EnhancedBookmarkModel* bookmark_model);
28 virtual ~BookmarkServerSearchService();
30 // Triggers a search. The query must not be empty. A call to this method
31 // cancels any previous searches. OnChange() is garanteed to be called once
32 // per query.
33 void Search(const std::string& query);
35 // Returns the search results. The results are only available after the
36 // OnChange() observer methods has been sent. This method will return an empty
37 // result otherwise. query should be a string passed to Search() previously.
38 std::vector<const BookmarkNode*> ResultForQuery(const std::string& query);
40 protected:
42 virtual net::URLFetcher* CreateFetcher() OVERRIDE;
44 virtual bool ProcessResponse(const std::string& response,
45 bool* should_notify) OVERRIDE;
47 virtual void CleanAfterFailure() OVERRIDE;
49 // EnhancedBookmarkModelObserver methods.
50 virtual void EnhancedBookmarkModelLoaded() OVERRIDE{};
51 virtual void EnhancedBookmarkAdded(const BookmarkNode* node) OVERRIDE;
52 virtual void EnhancedBookmarkRemoved(const BookmarkNode* node) OVERRIDE{};
53 virtual void EnhancedBookmarkAllUserNodesRemoved() OVERRIDE;
54 virtual void EnhancedBookmarkRemoteIdChanged(
55 const BookmarkNode* node,
56 const std::string& old_remote_id,
57 const std::string& remote_id) OVERRIDE;
59 private:
60 // The search data, a map from query to a vector of stars.id.
61 std::map<std::string, std::vector<std::string> > searches_;
62 std::string current_query_;
63 DISALLOW_COPY_AND_ASSIGN(BookmarkServerSearchService);
65 } // namespace enhanced_bookmarks
67 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_