| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_ |
| 6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_ | 6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } // namespace base | 23 } // namespace base |
| 24 | 24 |
| 25 namespace suggestions { | 25 namespace suggestions { |
| 26 | 26 |
| 27 // SuggestionsSource renders a webpage to list SuggestionsService data. | 27 // SuggestionsSource renders a webpage to list SuggestionsService data. |
| 28 class SuggestionsSource : public content::URLDataSource { | 28 class SuggestionsSource : public content::URLDataSource { |
| 29 public: | 29 public: |
| 30 explicit SuggestionsSource(Profile* profile); | 30 explicit SuggestionsSource(Profile* profile); |
| 31 | 31 |
| 32 // content::URLDataSource implementation. | 32 // content::URLDataSource implementation. |
| 33 virtual std::string GetSource() const override; | 33 std::string GetSource() const override; |
| 34 virtual void StartDataRequest( | 34 void StartDataRequest( |
| 35 const std::string& path, int render_process_id, int render_frame_id, | 35 const std::string& path, |
| 36 int render_process_id, |
| 37 int render_frame_id, |
| 36 const content::URLDataSource::GotDataCallback& callback) override; | 38 const content::URLDataSource::GotDataCallback& callback) override; |
| 37 virtual std::string GetMimeType(const std::string& path) const override; | 39 std::string GetMimeType(const std::string& path) const override; |
| 38 virtual base::MessageLoop* MessageLoopForRequestPath( | 40 base::MessageLoop* MessageLoopForRequestPath( |
| 39 const std::string& path) const override; | 41 const std::string& path) const override; |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 virtual ~SuggestionsSource(); | 44 ~SuggestionsSource() override; |
| 43 | 45 |
| 44 // Container for the state of a request. | 46 // Container for the state of a request. |
| 45 struct RequestContext { | 47 struct RequestContext { |
| 46 RequestContext( | 48 RequestContext( |
| 47 const suggestions::SuggestionsProfile& suggestions_profile_in, | 49 const suggestions::SuggestionsProfile& suggestions_profile_in, |
| 48 const content::URLDataSource::GotDataCallback& callback_in); | 50 const content::URLDataSource::GotDataCallback& callback_in); |
| 49 ~RequestContext(); | 51 ~RequestContext(); |
| 50 | 52 |
| 51 const suggestions::SuggestionsProfile suggestions_profile; | 53 const suggestions::SuggestionsProfile suggestions_profile; |
| 52 const content::URLDataSource::GotDataCallback callback; | 54 const content::URLDataSource::GotDataCallback callback; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 | 73 |
| 72 // For callbacks may be run after destruction. | 74 // For callbacks may be run after destruction. |
| 73 base::WeakPtrFactory<SuggestionsSource> weak_ptr_factory_; | 75 base::WeakPtrFactory<SuggestionsSource> weak_ptr_factory_; |
| 74 | 76 |
| 75 DISALLOW_COPY_AND_ASSIGN(SuggestionsSource); | 77 DISALLOW_COPY_AND_ASSIGN(SuggestionsSource); |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 } // namespace suggestions | 80 } // namespace suggestions |
| 79 | 81 |
| 80 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_ | 82 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_ |
| OLD | NEW |