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

Side by Side Diff: chrome/renderer/worker_permission_client_proxy.cc

Issue 273513005: Avoid sync IPCs for FileSystem API [chromium] (2/4) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add the missing code changes for shared worker. 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/render_messages.h" 5 #include "chrome/common/render_messages.h"
6 #include "chrome/renderer/worker_permission_client_proxy.h" 6 #include "chrome/renderer/worker_permission_client_proxy.h"
7 #include "content/public/renderer/render_frame.h" 7 #include "content/public/renderer/render_frame.h"
8 #include "content/public/renderer/render_thread.h" 8 #include "content/public/renderer/render_thread.h"
9 #include "ipc/ipc_sync_message_filter.h" 9 #include "ipc/ipc_sync_message_filter.h"
10 #include "third_party/WebKit/public/platform/WebPermissionCallbacks.h"
10 #include "third_party/WebKit/public/web/WebDocument.h" 11 #include "third_party/WebKit/public/web/WebDocument.h"
11 #include "third_party/WebKit/public/web/WebFrame.h" 12 #include "third_party/WebKit/public/web/WebFrame.h"
12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 13 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
13 14
14 WorkerPermissionClientProxy::WorkerPermissionClientProxy( 15 WorkerPermissionClientProxy::WorkerPermissionClientProxy(
15 content::RenderFrame* render_frame, 16 content::RenderFrame* render_frame,
16 blink::WebFrame* frame) 17 blink::WebFrame* frame)
17 : routing_id_(render_frame->GetRoutingID()), 18 : routing_id_(render_frame->GetRoutingID()),
18 is_unique_origin_(false) { 19 is_unique_origin_(false) {
19 if (frame->document().securityOrigin().isUnique() || 20 if (frame->document().securityOrigin().isUnique() ||
(...skipping 19 matching lines...) Expand all
39 routing_id_, document_origin_url_, top_frame_origin_url_, 40 routing_id_, document_origin_url_, top_frame_origin_url_,
40 name, display_name, &result)); 41 name, display_name, &result));
41 return result; 42 return result;
42 } 43 }
43 44
44 bool WorkerPermissionClientProxy::allowFileSystem() { 45 bool WorkerPermissionClientProxy::allowFileSystem() {
45 if (is_unique_origin_) 46 if (is_unique_origin_)
46 return false; 47 return false;
47 48
48 bool result = false; 49 bool result = false;
49 sync_message_filter_->Send(new ChromeViewHostMsg_AllowFileSystem( 50 sync_message_filter_->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync(
50 routing_id_, document_origin_url_, top_frame_origin_url_, &result)); 51 routing_id_, document_origin_url_, top_frame_origin_url_, &result));
51 return result; 52 return result;
52 } 53 }
53 54
55 bool WorkerPermissionClientProxy::requestFileSystemAccessSync() {
56 if (is_unique_origin_)
57 return false;
58
59 bool result = false;
60 sync_message_filter_->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync(
61 routing_id_, document_origin_url_, top_frame_origin_url_, &result));
62 return result;
63 }
64
65 void WorkerPermissionClientProxy::requestFileSystemAccessAsync(
66 const blink::WebPermissionCallbacks& callbacks) {
67 bool result = false;
68
69 // There are two reasons the we still send a synchronized message here:
70 // 1. This function is called in blink's worker thread. Therefore, sending
71 // synchronized message will only block the worker's thread, but won't block
72 // the main thread of the browser.
Fady Samuel 2014/05/15 16:08:09 the main thread. Remove "of the browser", we are n
Xi Han 2014/05/15 16:19:58 Done.
73 // 2. Compare with sending a asynchronized message, reuse sync_message_filter
Fady Samuel 2014/05/15 16:08:09 // 2. The sync filesystem API requires blocking. U
Xi Han 2014/05/15 16:19:58 Thanks for updating the comments. On 2014/05/15 1
74 // will largely reduces the code complexity.
75 sync_message_filter_->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync(
76 routing_id_, document_origin_url_, top_frame_origin_url_, &result));
77 blink::WebPermissionCallbacks permission_callbacks(callbacks);
78 if (result) {
79 permission_callbacks.doAllow();
80 return;
81 }
82 permission_callbacks.doDeny();
83 }
84
54 bool WorkerPermissionClientProxy::allowIndexedDB( 85 bool WorkerPermissionClientProxy::allowIndexedDB(
55 const blink::WebString& name) { 86 const blink::WebString& name) {
56 if (is_unique_origin_) 87 if (is_unique_origin_)
57 return false; 88 return false;
58 89
59 bool result = false; 90 bool result = false;
60 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB( 91 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB(
61 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result)); 92 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result));
62 return result; 93 return result;
63 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698