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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h"
13 #include "chrome/browser/chromeos/drive/file_system_interface.h"
14 #include "google_apis/drive/gdata_errorcode.h"
17 class SequencedTaskRunner
;
20 namespace google_apis
{
23 } // namespace google_apis
30 class ResourceMetadata
;
31 } // namespace internal
33 namespace file_system
{
35 // This class encapsulates the drive Search function. It is responsible for
36 // sending the request to the drive API.
37 class SearchOperation
{
39 SearchOperation(base::SequencedTaskRunner
* blocking_task_runner
,
40 JobScheduler
* scheduler
,
41 internal::ResourceMetadata
* metadata
);
44 // Performs server side content search operation for |search_query|. If
45 // |next_link| is set, this is the search result url that will be fetched.
46 // Upon completion, |callback| will be called with the result. This is
47 // implementation of FileSystemInterface::Search() method.
49 // |callback| must not be null.
50 void Search(const std::string
& search_query
,
51 const GURL
& next_link
,
52 const SearchCallback
& callback
);
55 // Part of Search(), called after the ResourceList is fetched from the server.
56 void SearchAfterGetResourceList(
57 const SearchCallback
& callback
,
58 google_apis::GDataErrorCode gdata_error
,
59 scoped_ptr
<google_apis::ResourceList
> resource_list
);
61 // Part of Search(), called after |result| is filled on the blocking pool.
62 void SearchAfterResolveSearchResult(
63 const SearchCallback
& callback
,
64 const GURL
& next_link
,
65 scoped_ptr
<std::vector
<SearchResultInfo
> > result
,
68 scoped_refptr
<base::SequencedTaskRunner
> blocking_task_runner_
;
69 JobScheduler
* scheduler_
;
70 internal::ResourceMetadata
* metadata_
;
72 // Note: This should remain the last member so it'll be destroyed and
73 // invalidate the weak pointers before any other members are destroyed.
74 base::WeakPtrFactory
<SearchOperation
> weak_ptr_factory_
;
75 DISALLOW_COPY_AND_ASSIGN(SearchOperation
);
78 } // namespace file_system
81 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_