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

Side by Side Diff: chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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
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 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" 5 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "chrome/browser/extensions/event_names.h" 10 #include "chrome/browser/extensions/event_names.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return; 53 return;
54 54
55 std::pair<int, int> key = std::make_pair(render_process_id, render_view_id); 55 std::pair<int, int> key = std::make_pair(render_process_id, render_view_id);
56 56
57 DeviceCaptureRequestMap::iterator request_it = requests_.find(key); 57 DeviceCaptureRequestMap::iterator request_it = requests_.find(key);
58 if (request_it == requests_.end()) { 58 if (request_it == requests_.end()) {
59 LOG(ERROR) << "Receiving updates for invalid tab capture request."; 59 LOG(ERROR) << "Receiving updates for invalid tab capture request.";
60 return; 60 return;
61 } 61 }
62 62
63 tab_capture::TabCaptureState state = 63 tab_capture::TabCaptureState state = tab_capture::TAB_CAPTURE_STATE_NONE;
64 tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_NONE;
65 switch (new_state) { 64 switch (new_state) {
66 case content::MEDIA_REQUEST_STATE_REQUESTED: 65 case content::MEDIA_REQUEST_STATE_REQUESTED:
67 state = tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_REQUESTED; 66 state = tab_capture::TAB_CAPTURE_STATE_REQUESTED;
68 break; 67 break;
69 case content::MEDIA_REQUEST_STATE_PENDING_APPROVAL: 68 case content::MEDIA_REQUEST_STATE_PENDING_APPROVAL:
70 state = tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_PENDING; 69 state = tab_capture::TAB_CAPTURE_STATE_PENDING;
71 break; 70 break;
72 case content::MEDIA_REQUEST_STATE_DONE: 71 case content::MEDIA_REQUEST_STATE_DONE:
73 state = tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_ACTIVE; 72 state = tab_capture::TAB_CAPTURE_STATE_ACTIVE;
74 break; 73 break;
75 case content::MEDIA_REQUEST_STATE_CLOSING: 74 case content::MEDIA_REQUEST_STATE_CLOSING:
76 state = tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_STOPPED; 75 state = tab_capture::TAB_CAPTURE_STATE_STOPPED;
77 break; 76 break;
78 case content::MEDIA_REQUEST_STATE_ERROR: 77 case content::MEDIA_REQUEST_STATE_ERROR:
79 state = tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_ERROR; 78 state = tab_capture::TAB_CAPTURE_STATE_ERROR;
80 break; 79 break;
81 default: 80 default:
82 // TODO(justinlin): Implement muted state notification. 81 // TODO(justinlin): Implement muted state notification.
83 break; 82 break;
84 } 83 }
85 84
86 if (state == tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_NONE) { 85 if (state == tab_capture::TAB_CAPTURE_STATE_NONE) {
87 // This is a state we don't handle. 86 // This is a state we don't handle.
88 return; 87 return;
89 } 88 }
90 89
91 TabCaptureRegistry::TabCaptureRequest* request_info = &request_it->second; 90 TabCaptureRegistry::TabCaptureRequest* request_info = &request_it->second;
92 request_info->status = state; 91 request_info->status = state;
93 92
94 scoped_ptr<tab_capture::CaptureInfo> info(new tab_capture::CaptureInfo()); 93 scoped_ptr<tab_capture::CaptureInfo> info(new tab_capture::CaptureInfo());
95 info->tab_id = request_info->tab_id; 94 info->tab_id = request_info->tab_id;
96 info->status = request_info->status; 95 info->status = request_info->status;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 136 }
138 } 137 }
139 } 138 }
140 139
141 bool TabCaptureRegistry::AddRequest(const std::pair<int, int> key, 140 bool TabCaptureRegistry::AddRequest(const std::pair<int, int> key,
142 const TabCaptureRequest& request) { 141 const TabCaptureRequest& request) {
143 // Currently, we do not allow multiple active captures for same tab. 142 // Currently, we do not allow multiple active captures for same tab.
144 DeviceCaptureRequestMap::iterator it = requests_.find(key); 143 DeviceCaptureRequestMap::iterator it = requests_.find(key);
145 if (it != requests_.end()) { 144 if (it != requests_.end()) {
146 const tab_capture::TabCaptureState state = it->second.status; 145 const tab_capture::TabCaptureState state = it->second.status;
147 if (state != tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_STOPPED && 146 if (state != tab_capture::TAB_CAPTURE_STATE_STOPPED &&
148 state != tab_capture::TAB_CAPTURE_TAB_CAPTURE_STATE_ERROR) 147 state != tab_capture::TAB_CAPTURE_STATE_ERROR)
149 return false; 148 return false;
150 } 149 }
151 requests_.insert(std::make_pair(key, request)); 150 requests_.insert(std::make_pair(key, request));
152 return true; 151 return true;
153 } 152 }
154 153
155 bool TabCaptureRegistry::VerifyRequest(int render_process_id, 154 bool TabCaptureRegistry::VerifyRequest(int render_process_id,
156 int render_view_id) { 155 int render_view_id) {
157 return requests_.find(std::make_pair( 156 return requests_.find(std::make_pair(
158 render_process_id, render_view_id)) != requests_.end(); 157 render_process_id, render_view_id)) != requests_.end();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 const content::MediaStreamDevice& device, 208 const content::MediaStreamDevice& device,
210 const content::MediaRequestState new_state) { 209 const content::MediaRequestState new_state) {
211 if (handler_) 210 if (handler_)
212 handler_->HandleRequestUpdateOnUIThread(render_process_id, 211 handler_->HandleRequestUpdateOnUIThread(render_process_id,
213 render_view_id, 212 render_view_id,
214 device, 213 device,
215 new_state); 214 new_state);
216 } 215 }
217 216
218 } // namespace extensions 217 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tab_capture/tab_capture_api.cc ('k') | chrome/browser/extensions/api/usb/usb_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698