Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/extensions/api/streams_private/streams_private_api.h

Issue 281513003: Implement chrome.streamsPrivate.abort() extensions function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/streams_private/streams_private_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "extensions/browser/api/async_api_function.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h" 13 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/extension_function.h" 14 #include "extensions/browser/extension_function.h"
14 #include "extensions/browser/extension_registry_observer.h" 15 #include "extensions/browser/extension_registry_observer.h"
15 16
16 namespace content { 17 namespace content {
17 class BrowserContext; 18 class BrowserContext;
18 class StreamHandle; 19 class StreamHandle;
19 } 20 }
20 21
21 namespace extensions { 22 namespace extensions {
22 class ExtensionRegistry; 23 class ExtensionRegistry;
23 24
24 class StreamsPrivateAPI : public BrowserContextKeyedAPI, 25 class StreamsPrivateAPI : public BrowserContextKeyedAPI,
25 public ExtensionRegistryObserver { 26 public ExtensionRegistryObserver {
26 public: 27 public:
27 // Convenience method to get the StreamsPrivateAPI for a BrowserContext. 28 // Convenience method to get the StreamsPrivateAPI for a BrowserContext.
28 static StreamsPrivateAPI* Get(content::BrowserContext* context); 29 static StreamsPrivateAPI* Get(content::BrowserContext* context);
29 30
30 explicit StreamsPrivateAPI(content::BrowserContext* context); 31 explicit StreamsPrivateAPI(content::BrowserContext* context);
31 virtual ~StreamsPrivateAPI(); 32 virtual ~StreamsPrivateAPI();
32 33
33 void ExecuteMimeTypeHandler(const std::string& extension_id, 34 void ExecuteMimeTypeHandler(const std::string& extension_id,
34 content::WebContents* web_contents, 35 content::WebContents* web_contents,
35 scoped_ptr<content::StreamHandle> stream, 36 scoped_ptr<content::StreamHandle> stream,
36 int64 expected_content_size); 37 int64 expected_content_size);
37 38
39 void AbortStream(const std::string& extension_id,
40 const GURL& stream_url);
41
38 // BrowserContextKeyedAPI implementation. 42 // BrowserContextKeyedAPI implementation.
39 static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance(); 43 static BrowserContextKeyedAPIFactory<StreamsPrivateAPI>* GetFactoryInstance();
40 44
41 private: 45 private:
42 friend class BrowserContextKeyedAPIFactory<StreamsPrivateAPI>; 46 friend class BrowserContextKeyedAPIFactory<StreamsPrivateAPI>;
43 typedef std::map<std::string, 47 typedef std::map<std::string,
44 std::map<GURL, 48 std::map<GURL,
45 linked_ptr<content::StreamHandle> > > StreamMap; 49 linked_ptr<content::StreamHandle> > > StreamMap;
46 50
47 // ExtensionRegistryObserver implementation. 51 // ExtensionRegistryObserver implementation.
(...skipping 11 matching lines...) Expand all
59 63
60 content::BrowserContext* const browser_context_; 64 content::BrowserContext* const browser_context_;
61 StreamMap streams_; 65 StreamMap streams_;
62 base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_; 66 base::WeakPtrFactory<StreamsPrivateAPI> weak_ptr_factory_;
63 67
64 // Listen to extension unloaded notifications. 68 // Listen to extension unloaded notifications.
65 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 69 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
66 extension_registry_observer_; 70 extension_registry_observer_;
67 }; 71 };
68 72
73 class StreamsPrivateAbortFunction : public AsyncApiFunction {
Zachary Kuznia 2014/05/15 13:43:27 Is there a reason you don't derive from SyncExtens
raymes 2014/05/16 01:09:19 Done.
74 public:
75 StreamsPrivateAbortFunction();
76 DECLARE_EXTENSION_FUNCTION("streamsPrivate.abort", STREAMSPRIVATE_ABORT)
77
78 protected:
79 virtual ~StreamsPrivateAbortFunction() {}
80
81 // AsyncApiFunction:
82 virtual bool Prepare() OVERRIDE;
83 virtual bool Respond() OVERRIDE;
84
85 private:
86 std::string stream_url_;
87 };
88
69 } // namespace extensions 89 } // namespace extensions
70 90
71 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_ 91 #endif // CHROME_BROWSER_EXTENSIONS_API_STREAMS_PRIVATE_STREAMS_PRIVATE_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/streams_private/streams_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698