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

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.cc

Issue 2572683004: mediaview: Introduce ArcDocumentsProviderRoot. (Closed)
Patch Set: Remove unused functions. Created 4 years 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
6
7 #include <vector>
8
9 #include "base/strings/string_util.h"
10 #include "storage/browser/fileapi/file_system_url.h"
11
12 namespace arc {
13
14 namespace {
15
16 constexpr base::FilePath::CharType kSpecialDirectory[] =
17 FILE_PATH_LITERAL("special");
18
19 } // namespace
20
21 bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url,
22 std::string* authority,
23 std::string* root_document_id,
24 base::FilePath* path) {
25 if (url.type() != storage::kFileSystemTypeArcDocumentsProvider) {
Luis Héctor Chávez 2016/12/14 20:53:50 nit: elide braces
Shuhei Takahashi 2016/12/15 02:37:55 Done.
26 return false;
27 }
28
29 // Filesystem URL format for documents provider is:
30 // /special/arc-documents-provider/<authority>/<root_doc_id>/<relative_path>
31 using Components = std::vector<base::FilePath::StringType>;
32 Components components;
33 url.path().GetComponents(&components);
34 if (components.size() < 5 || components[0] != FILE_PATH_LITERAL("/") ||
Luis Héctor Chávez 2016/12/14 20:53:50 re: components[0] != FILE_PATH_LITERAL("/"). Does
Shuhei Takahashi 2016/12/15 02:37:55 Strictly, those two conditions are different. If t
Luis Héctor Chávez 2016/12/15 21:26:10 Got it, thanks for your explanation.
35 components[1] != kSpecialDirectory ||
36 components[2] != kDocumentsProviderMountPointName) {
37 return false;
38 }
39
40 *authority = components[3];
41 *root_document_id = components[4];
42 *path = base::FilePath::FromUTF8Unsafe(base::JoinString(
43 Components(components.begin() + 5, components.end()), "/"));
44 DCHECK(!path->IsAbsolute());
Luis Héctor Chávez 2016/12/14 20:53:50 nit: compute the path in a temporary and move the
Shuhei Takahashi 2016/12/15 02:37:55 Hmm, if we return false in the failure case it mak
45 return true;
46 }
47
48 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698