Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
| 17 #include "content/browser/download/download_item.h" | 17 #include "content/browser/download/download_item.h" |
| 18 #include "content/browser/download/download_query.h" | |
|
asanka
2011/10/20 19:29:16
Nit: ordering.
| |
| 18 #include "content/browser/download/download_manager.h" | 19 #include "content/browser/download/download_manager.h" |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class DictionaryValue; | 22 class DictionaryValue; |
| 22 } | 23 } |
| 23 class ResourceDispatcherHost; | 24 class ResourceDispatcherHost; |
| 24 class TabContents; | 25 class TabContents; |
| 25 namespace content { | 26 namespace content { |
| 26 class ResourceContext; | 27 class ResourceContext; |
| 27 } | 28 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 }; | 123 }; |
| 123 void BeginDownloadOnIOThread(); | 124 void BeginDownloadOnIOThread(); |
| 124 void OnStarted(DownloadId dl_id, net::Error error); | 125 void OnStarted(DownloadId dl_id, net::Error error); |
| 125 void RespondOnUIThread(int dl_id, net::Error error); | 126 void RespondOnUIThread(int dl_id, net::Error error); |
| 126 | 127 |
| 127 scoped_ptr<IOData> iodata_; | 128 scoped_ptr<IOData> iodata_; |
| 128 | 129 |
| 129 DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); | 130 DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 class DownloadsSearchFunction : public SyncDownloadsFunction { | 133 class DownloadsSearchFunction : public SyncDownloadsFunction { |
|
cbentzel
2011/10/20 18:18:53
Should this be an AsyncDownloadsFunction function?
| |
| 133 public: | 134 public: |
| 134 DownloadsSearchFunction(); | 135 DownloadsSearchFunction(); |
| 135 virtual ~DownloadsSearchFunction(); | 136 virtual ~DownloadsSearchFunction(); |
| 136 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.search"); | 137 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.search"); |
| 137 | 138 |
| 138 protected: | 139 protected: |
| 139 virtual bool ParseArgs() OVERRIDE; | 140 virtual bool ParseArgs() OVERRIDE; |
|
cbentzel
2011/10/20 18:18:53
For testing purposes, it might be nice to have a
| |
| 140 virtual void RunInternal() OVERRIDE; | 141 virtual void RunInternal() OVERRIDE; |
| 141 | 142 |
| 142 private: | 143 private: |
| 144 template <typename ValueType> | |
| 145 bool Parse(base::DictionaryValue* json, const char* json_name, | |
| 146 download_util::DownloadQuery::FilterFieldName filter_name); | |
| 147 | |
| 148 download_util::DownloadQuery query_; | |
|
cbentzel
2011/10/20 18:18:53
Could you make this a scoped_ptr so you can just f
| |
| 149 int get_id_; | |
| 150 bool has_get_id_; | |
| 151 | |
| 143 DISALLOW_COPY_AND_ASSIGN(DownloadsSearchFunction); | 152 DISALLOW_COPY_AND_ASSIGN(DownloadsSearchFunction); |
| 144 }; | 153 }; |
| 145 | 154 |
| 146 class DownloadsPauseFunction : public SyncDownloadsFunction { | 155 class DownloadsPauseFunction : public SyncDownloadsFunction { |
| 147 public: | 156 public: |
| 148 DownloadsPauseFunction(); | 157 DownloadsPauseFunction(); |
| 149 virtual ~DownloadsPauseFunction(); | 158 virtual ~DownloadsPauseFunction(); |
| 150 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.pause"); | 159 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.pause"); |
| 151 | 160 |
| 152 protected: | 161 protected: |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 typedef base::hash_map<int, DownloadItem*> ItemMap; | 277 typedef base::hash_map<int, DownloadItem*> ItemMap; |
| 269 typedef std::set<int> DownloadIdSet; | 278 typedef std::set<int> DownloadIdSet; |
| 270 | 279 |
| 271 Profile* profile_; | 280 Profile* profile_; |
| 272 DownloadManager* manager_; | 281 DownloadManager* manager_; |
| 273 DownloadIdSet downloads_; | 282 DownloadIdSet downloads_; |
| 274 | 283 |
| 275 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); | 284 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); |
| 276 }; | 285 }; |
| 277 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | 286 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ |
| OLD | NEW |